Solvedsequelize typescript Type 'typeof Player' is not assignable to type 'typeof Model'


  • sequelize: sequelize@6.3.5
  • sequelize-typescript: sequelize-typescript@1.1.0
  • typescrip: typescript@4.0.2

I'm submitting a ...

[X] bug report
[ ] feature request

Actual behavior:
I have added 2 class files, Player.ts and Team.ts as per the example. In each of the references:

  @HasMany(() => Player)


  @ForeignKey(() => Team)
  teamId: number;
  @BelongsTo(() => Team)
  team: Team;

The Team and the Player following the => on the attribute is underlines in red in VS code with the error:

Type 'typeof Team' is not assignable to type 'typeof Model'.
  Construct signature return types 'Team' and 'Model<T, T2>' are incompatible.
    The types of '_attributes' are incompatible between these types.
      Type 'Team' is not assignable to type 'T'.
        'T' could be instantiated with an arbitrary type which could be unrelated to 'Team'.ts(2322)
model-class-getter.d.ts(2, 40): The expected type comes from the return type of this signature.

Expected behavior:
No Errors

Steps to reproduce:
Added Player.ts with the sample code provided in the, and Team.ts in the same way

Related code:

import { Table, Model, Column, ForeignKey, BelongsTo } from 'sequelize-typescript'

export class Player extends Model<Player> {
  name: string;
  num: number;
  @ForeignKey(() => Team)
  teamId: number;
  @BelongsTo(() => Team)
  team: Team;


import { Table, Model, Column, ForeignKey, HasMany } from 'sequelize-typescript'
import { Player } from './Player';

export class Team extends Model<Team> {
  name: string;
  @HasMany(() => Player)
  players: Player[];
20 Answers

✔️Accepted Answer

You can use sequelize^6.3.5 + sequelize-typescript^2.0.0-beta.1, you only need to remove argument from Model<...>:

-export class Team extends Model<Team> {
+export class Team extends Model {

Thanks to @lukashroch for updated docs:

Other Answers:

It's related to sequelize@6.3.5. I have the same issue with both sequelize-typescript @1.1.0 & @2.0.0-beta.0

If I downgrade to sequelize@5.22.0 the issue is gone.

It must be a change in the sequelize Model type which is not compatible with the decorators typing.

Already reported in: #828, #826, #821 #813

Looks like using sequelize@6.1.1 solve the issue for now, which is the last version of sequelize with Model type compatible with sequelize-typescript.

I have the same problem with

"sequelize": "^6.3.5",
"sequelize-typescript": "^2.0.0-beta.0"


"sequelize": "^6.1.1",
"sequelize-typescript": "^2.0.0-beta.0"

resolved with downgrade to

"sequelize": "^5.22.0",
"sequelize-typescript": "^1.1.0"

Thanks your proposal can solve the issue

Hello @Austine105, did you found any solution for this issue ? I have the same problem with nest.js

Same here, @RobinBuschmann any idea what's going on?

Related Issues:

sequelize typescript Type 'typeof Player' is not assignable to type 'typeof Model'
You can use sequelize^6.3.5 + sequelize-typescript^2.0.0-beta.1 Versions sequelize: sequelize@6.3.5 ...
sequelize typescript Sequelize v5.13.0 not supported
Hey @justinlottes thanks for reporting Just published a new beta version (sequelize-typescript@1.0.0...
sequelize typescript Problems with multiple relationships
Hey @Dragons0458 your setup is totally fine The issue is the query itself Hi! ...
labelImg labelImg 1.5.2 on windows crashed
Just delete the file .labelImgSettings.pkl which is locate at C:\\Users\your_account\ Then reopen La...
labelImg Question: how to fix "ModuleNotFoundError: No module named 'libs.resources' "
Thx v much for that reference The following band-aid from that issue fixed for me: pyrcc5 -o libs/re...
swag cannot find type definition: gorm.Model
I am having the same issue: 2020/10/28 13:52:34 ParseComment error in file **/file/path/.go :cannot ...
swag Version 1.6.9 - cannot find type definition
For those who need a quick solution: go get -u ...
cvat Unable to remote connect
To help anyone out there with complete solution: Create in cvat home directory file docker-compose.o...
labelImg Cannot install on macOS High Sierra if I use qt4 and make qt4py2
This worked for me on OSX High Sierra: Hello guys.Just to let you know that the installation for mac...
labelme Unable to save: 'bytes' object has no attribute 'encode'
I tested in this way on windows and it worked In def save(...): with open(filename ...
label studio Encoding
@makseq I installed Label Studio with your realease/0.7.4 branch with the command : pip install --up...
type graphql Getting "Schema must contain uniquely named types but contains multiple types named" for a single type
This was a hard one to track down with an annoying fix (Nest specific not the fault of type-graphql)...
vue property decorator Property 'title' has no initializer and is not definitely assigned in the constructor.
Since you use the latest version of TS you mention the error Please see the section Strict Class Ini...
type graphql Cannot determine GraphQL input type for
For future readers This may have been due to using an @ObjectType() CompanyData as an @InputType() i...
type graphql Integration with Prisma
Hi @19majkel94! We're still very interested in supporting you with a seamless Prisma integration Giv...
class validator feat: add option to stop validation after first validation error
I agree Would be much efficient when no validators would run after one failed My example: IsInModel ...
type graphql Error when using GraphQLJSON
@darkmantle Setting: Means you should use default import: The latest version (0.15.0) seems to have ...
laravel mongodb Composer can't find mongodb extension
composer require jenssegers/mongodb --ignore-platform-reqs It solved my problem. ...
sequelize Class constructor Model cannot be invoked without 'new' and how getter v4 work?
Intypescript case my solution was to change target from es5 to es6 Hi all ...
typeorm Error: RepositoryNotFoundError: No repository for [Enitity] was found. Looks like this entity is not registered in current "default" connection? Issue type: [x] question [x] bug r...
prisma Prisma Migrate: Error creating shadow database
I just want to add a quick note for folks coming here from googling the error message that if you ar...
sequelize Sequelize intellisense doesn't work in Visual Studio Code
This looks like a bug with VSCode to be honest.. I just tried to reproduce What are you doing? I ins...
efcore No executable found matching command "dotnet-ef" even after adding CLI
I has this issue and like to share I want to Migrate my Database with Models I am using EF Core 2.0 ...
sequelize TimeoutError: ResourceRequest timed out
I have fixed the issue by maximizing the acquire option of pool configuration in sequelize I guess A...
diesel Could not compile diesel_cli
i install and it works Thanks Guys! Setup Versions Rust: rustc 1.33.0 (2aa4c46cf 2019-02-28) Databas...
efcore UseSqlServer() method is missing from Microsoft.EntityFrameworkCore.SqlServer 1.1.1
Hm - try manually adding the using statement using Microsoft.EntityFrameworkCore; and building again...
sequelize Using underscored: true still returns attributes in camelCase
Hello I was having the same problem as @twistedrc1017 with the timestamps created_ at and updated_at...
typeorm Relation decorators: allow to pass string instead of typeFunction
PR is submitted As an example Issue type: [ ] question [ ] bug report [x] feature request [ ] docume...
sequelize 4.0 Model definition syntax
After all night of tweaking I finally have a working example based on @leebenson and @felixfbecker's...
typeorm How to get foreign key for instance?
You can't do that because your group is relation object its not a simple number (id of the pricetagg...
typeorm MissingDriverError: Wrong driver: "undefined" given.
solved it by export the config this way in my ormconfig.ts: Issue type: [ ] question [X] bug report ...
sequelize Class constructor Model cannot be invoked without 'new'
@SimonSchick Interesting I didn't know that Indeed adding the following tsconfig.json to my root fol...
sequelize Please install mysql2 package manually
@arielrahmane wherever you import sequelize you can set the dialectModule in the options Example bel...
typeorm .save() is throwing duplicate key value violates unique constraint
I can confirm that this problem still exists I'm using typeorm with postgres. Issue type: [x] questi...
typeorm Error: Entity metadata was not found
I ran into the same issue TypeORM is very difficult to debug with args and meta data classes/collect...
sequelize Separate: true — Cannot read property 'push' of undefined
I got to make it work on my side by specifying the foreignKey in the included attributes I'm using s...
typeorm WHERE, Date, and BETWEEN
It appears that there is a bug with how QueryBuilder is handling dates I only tested with SQLite ...
efcore How to write DbFunction's translation?
@Kation You actually does not need so much of code to use JSON_VALUE function Based on documentation...
efcore Inheritance problem with DbContext subclasses requiring constructor to supply DbContextOptions<DerivedContext>
I was able to resolve this without a hack by providing a protected constructor that uses DbContextOp...
typeorm ER_NOT_SUPPORTED_AUTH_MODE after upgrade
I found a solution for docker --default-authentication-plugin=mysql_native_password ...
prisma1 Nested upsert in create mutations (correct: nested connectOrCreate)
We are thinking about implementing this soon Feature Request What feature are you missing? A nested ...
efcore MissingMethodException: Method not found: 'Boolean Microsoft.EntityFrameworkCore.Migrations.IMigrationsModelDiffer.HasDifferences
@AmSmart just to clarify in the documentation that @ajcvickers mentioned it gives updated code for t...
sequelize Error in sequelize.import: defineCall is not a function
That means you have tried to import a module that did not do a module.exports = function() { ...
typeorm { EntityMetadataNotFound: No metadata for "User" was found.
In my case I just needed to change this : Into this : Hello I'm trying to setup a new project using ...
diesel Installing diesel_cli on Windows : some assembly required
I think the best way to address this issue now is following these instructions: If you are using a s...
ef6 cannot bind argument to parameter 'path' because it is null
I realize that this issue is closed but I too have started seeing this issue and thought this might ...
efcore error NU1202: Package dotnet-ef 3.0.1 is not compatible with netcoreapp3.0
@bricelam Presumably the workaround for anyone hitting this is to install the 3.0.0 version explicit...
typeorm Migration cli unexpected token import
Anyone wondering about this you must run your .ts files thru ts-node first Simply: ...
typeorm ts-node throwing RepositoryNotFoundError
I also had the same No repository for .. in current default connection and it worked fine for develo...
typeorm many-to-many-relations with not default join table columns names
@DavidBM can you please provide a more detailed description of the issue you have and what you are t...