TypeScript: TS2.4 compile error with derived type assignment

TypeScript Version: 2.4.1

Code

// A *self-contained* demonstration of the problem follows...
export class City extends BaseModel {
  //...
}
export abstract class BaseModel extends Model {
  //...
}
export abstract class Model {
  //...
}

Expected behavior: compile without error Actual behavior:

error TS2345: Argument of type 'typeof City' is not assignable to parameter of type 'typeof Model'.
  Type 'City' is not assignable to type 'Model'.
    Types of property 'set' are incompatible.
      Type '{ <K extends "reload" | "isNewRecord" | "sequelize" | "aggregate" | "where" | "getDataValue" | "s...' is not assignable to type '{ <K extends "reload" | "isNewRecord" | "sequelize" | "aggregate" | "where" | "getDataValue" | "s...'. Two different types with this name exist, but they are unrelated.
        Type 'City' is not assignable to type 'Model'.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 21 (16 by maintainers)

Most upvoted comments

@kitsonk can you explain the wrong typing in this error?

error TS2684: The 'this' context of type 'typeof User' is not assignable to method's 'this' of type '(new () => User) & typeof Model'.
  Type 'typeof User' is not assignable to type 'typeof Model'

if User extends Model, then typeof User should be assignable to typeof Model, and it was in TS 2.3

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.