Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TS Config to support new decorators model definition #272

Merged
merged 4 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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