Closed
Description
I have code like so:
export class A<T> {
//
}
export type Constructor<T> = new (...args: any[]) => T;
export function foo<T extends Constructor<{}>>(Base: T): T & Constructor<{}> {
return class extends Base {};
}
export class B<T> extends foo<Constructor<A<T>>>(A) {}
(This is an over simplified version of real code just to show the problem)
The generated .d.ts
file does not compile
export declare class A<T> {}
export declare type Constructor<T> = new (...args: any[]) => T;
export declare function foo<T extends Constructor<{}>>(Base: T): T & Constructor<{}>;
declare const B_base: Constructor<A<T>> & Constructor<{}>;
export declare class B<T> extends B_base {}
As you can see the extending function is compiled to a const B_Base
and since consts can not be generic this line throws an error when using the definition file.