Skip to content

Commit

Permalink
Update TS Config to support new decorators model definition (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
johneatmon authored Mar 25, 2024
1 parent 1230359 commit 97871ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/sscce-sequelize-7.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DataTypes, Model } from '@sequelize/core';
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from '@sequelize/core';
import { Attribute, NotNull } from '@sequelize/core/decorators-legacy';
import { createSequelize7Instance } from '../dev/create-sequelize-instance';
import { expect } from 'chai';
import sinon from 'sinon';
Expand All @@ -21,14 +22,15 @@ export async function run() {
},
});

class Foo extends Model {}
class Foo extends Model<InferAttributes<Foo>, InferCreationAttributes<Foo>> {
declare id: CreationOptional<number>;

Foo.init({
name: DataTypes.TEXT,
}, {
sequelize,
modelName: 'Foo',
});
@Attribute(DataTypes.TEXT)
@NotNull
declare name: string;
}

sequelize.addModels([Foo]);

// You can use sinon and chai assertions directly in your SSCCE.
const spy = sinon.spy();
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
],
"compilerOptions": {
"target": "es2021",
"module": "CommonJS",
"moduleResolution": "Node",
"module": "nodenext",
"experimentalDecorators": true,
"moduleResolution": "nodenext",
"esModuleInterop": true,
"resolveJsonModule": true,
"newLine": "lf",
Expand Down

0 comments on commit 97871ef

Please sign in to comment.