diff --git a/src/model/model/model.ts b/src/model/model/model.ts index 86f38d53..63be8d12 100644 --- a/src/model/model/model.ts +++ b/src/model/model/model.ts @@ -7,9 +7,10 @@ import {AssociationGetOptions} from "./association/association-get-options"; import {AssociationCountOptions} from "./association/association-count-options"; import {AssociationActionOptions} from "./association/association-action-options"; import {AssociationCreateOptions} from "./association/association-create-options"; +import {Repository} from '../../sequelize/repository/repository'; export type ModelType = new (values?: TCreationAttributes, options?: any) => Model; -export type ModelCtor = (new () => M) & typeof Model; +export type ModelCtor = Repository; export type $GetType = NonNullable extends any[] ? NonNullable : (NonNullable | null); diff --git a/src/sequelize/sequelize/sequelize.ts b/src/sequelize/sequelize/sequelize.ts index 86d4fd2b..868f4fea 100644 --- a/src/sequelize/sequelize/sequelize.ts +++ b/src/sequelize/sequelize/sequelize.ts @@ -110,7 +110,7 @@ export class Sequelize extends OriginSequelize { } private createRepositoryModel(modelClass: ModelCtor): ModelCtor { - return class extends modelClass { + return class extends modelClass { }; } diff --git a/test/types/attributes.spec.ts b/test/types/attributes.spec.ts index 2a9b7f7f..155859f1 100644 --- a/test/types/attributes.spec.ts +++ b/test/types/attributes.spec.ts @@ -6,6 +6,8 @@ import { BelongsTo, BelongsToMany, ForeignKey, + PrimaryKey, + Sequelize, } from "../../src/index"; import { Column } from "../../src/model/column/column"; import { Model } from "../../src/model/model/model"; @@ -36,6 +38,7 @@ type PersonCreationAttributes = Optional; @Table export class Person extends Model { + @PrimaryKey @AutoIncrement @Column(DataType.INTEGER) id: number; @@ -46,6 +49,7 @@ export class Person extends Model { @Table export class Pet extends Model { + @PrimaryKey @AutoIncrement @Column(DataType.INTEGER) petId: number; @@ -71,3 +75,8 @@ export class Toy extends Model { @BelongsTo(() => Pet) pet: Pet; } + +function testTypes() { + // all models should be accepted + new Sequelize().addModels([Person, Pet, PetPerson]); +}