Skip to content

Commit 97871ef

Browse files
authored
Update TS Config to support new decorators model definition (#272)
1 parent 1230359 commit 97871ef

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/sscce-sequelize-7.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { DataTypes, Model } from '@sequelize/core';
1+
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from '@sequelize/core';
2+
import { Attribute, NotNull } from '@sequelize/core/decorators-legacy';
23
import { createSequelize7Instance } from '../dev/create-sequelize-instance';
34
import { expect } from 'chai';
45
import sinon from 'sinon';
@@ -21,14 +22,15 @@ export async function run() {
2122
},
2223
});
2324

24-
class Foo extends Model {}
25+
class Foo extends Model<InferAttributes<Foo>, InferCreationAttributes<Foo>> {
26+
declare id: CreationOptional<number>;
2527

26-
Foo.init({
27-
name: DataTypes.TEXT,
28-
}, {
29-
sequelize,
30-
modelName: 'Foo',
31-
});
28+
@Attribute(DataTypes.TEXT)
29+
@NotNull
30+
declare name: string;
31+
}
32+
33+
sequelize.addModels([Foo]);
3234

3335
// You can use sinon and chai assertions directly in your SSCCE.
3436
const spy = sinon.spy();

tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
],
66
"compilerOptions": {
77
"target": "es2021",
8-
"module": "CommonJS",
9-
"moduleResolution": "Node",
8+
"module": "nodenext",
9+
"experimentalDecorators": true,
10+
"moduleResolution": "nodenext",
1011
"esModuleInterop": true,
1112
"resolveJsonModule": true,
1213
"newLine": "lf",

0 commit comments

Comments
 (0)