You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Problem with declaration file generated from generic extended function #17840
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.
Activity
weswigham commentedon Nov 10, 2017
This is now an error, as per #17922