I have a generic class of typescript with 2 properties as -
export class WrapperModel<T>{
constructor(private testType: new () => T) {
this.getNew();
}
getNew(): T {
return new this.testType();
}
public Entity: T;
public ShowLoading: boolean;
}
Then using it as follows -
this.userModel = new WrapperModel<UserProfileModel>(UserProfileModel);
I am assuming it is creating an instance of type UserProfileModel in its constructor.
But when I try with Array type property then it fails. Like when I do -
this.userModel = new WrapperModel<Array<UserProfileModel>>(Array<UserProfileModel>);
The error which I get in above case -
Is it I cannot create an instance of Array property in generics or something else.
My need is simple; I want to create instance of Array properties in Generic class.
