-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
Throw error: Base constructor return type 'T' is not a class or interface type
interface BaseClass<T> {
new (): T
}
function generateUserClass<T>(baseClass: BaseClass<T>){
return class extends baseClass {
name: string;
}
}Error: Type any is not constructor function type
function generateUserClass<T>(baseClass: any){
return class extends baseClass {
name: string;
}
}But if we specify generic it's work
function generateUserClass(baseClass: BaseClass<Foo>){
return class extends baseClass {
name: string;
}
}Throw error: Base constructor return type 'IUser & Base' is not a class or interface type
interface IUser {
name: string;
}
interface IUserClass<T>{
new (): IUser & T;
}
function genUserCls<T>(base: new ()=>T): IUserClass<T> {
return null;
}
class Base{
foo(){}
}
class User extends genUserCls(Base) {}TS version: 1.8
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created