I want to have base model:
export class BaseModel<T> {
public static create(obj:any):T {
let instance = _.assignIn(new T(), obj);
return instance;
}
}
and then, specific model:
export class MyModel: BaseModel<MyModel> {
public prop1:string;
}
then, I want to create models in the following way:
let myModel = MyModel.create(...);
But, I can't force it work and get error:
'T' only refers to a type, but is being used as a value here.
create. Define it likecreate(cls: {new(): T}, obj: any) { ... assignIn(new cls(), obj); ...}, use it likeMyModel.create(MyModel, ...).