What is the reason behind not being able to assign a reference to a derived class to a variable if the reference type is a parent class with Generics?
interface IModel {
id?: number;
}
class Model<T extends IModel> {
public data: T;
constructor(data: T) {
this.data = data;
}
}
interface IConcretModel extends IModel {
name: string;
}
class ConcretModel extends Model<IConcretModel> {
static sm1() { }
}
let a: typeof Model;
a = ConcretModel;
An error occurs on the last line:
Type 'typeof ConcretModel' is not assignable to type 'typeof Model'.
Types of parameters 'data' and 'data' are incompatible.
Type 'T' is not assignable to type 'IConcretModel'.
Type 'IModel' is not assignable to type 'IConcretModel'.
Property 'name' is missing in type 'IModel'.