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 #267

Closed
wants to merge 5 commits into from
Closed
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
26 changes: 23 additions & 3 deletions src/sscce-sequelize-7.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { DataTypes, Model } from '@sequelize/core';
import { CreationOptional, DataTypes, Model } from "@sequelize/core";
import {
Attribute,
AutoIncrement,
NotNull,
PrimaryKey,
} from "@sequelize/core/decorators-legacy";
import { createSequelize7Instance } from '../dev/create-sequelize-instance';
import { expect } from 'chai';
import sinon from 'sinon';
import { expect } from "chai";
import sinon from "sinon";

// if your issue is dialect specific, remove the dialects you don't need to test on.
export const testingOnDialects = new Set(['mssql', 'sqlite', 'mysql', 'mariadb', 'postgres', 'postgres-native']);
Expand Down Expand Up @@ -30,6 +36,20 @@ export async function run() {
modelName: 'Foo',
});

// You can also use the new decorators model definition
class Bar extends Model {
@Attribute(DataTypes.INTEGER)
@PrimaryKey
@AutoIncrement
declare id: CreationOptional<number>;

@Attribute(DataTypes.TEXT)
@NotNull
declare name: string;
}

sequelize.addModels([Bar]);

// You can use sinon and chai assertions directly in your SSCCE.
const spy = sinon.spy();
sequelize.afterBulkSync(() => 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