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)
@kitsonk can you explain the wrong typing in this error?
if
User
extendsModel
, thentypeof User
should be assignable totypeof Model
, and it was in TS 2.3Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.