-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
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.
nayish, AdirAmsalem, felixmosh, avivr, cooperd and 2 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesThe issue relates to the emission of d.ts filesFixedA PR has been merged for this issueA PR has been merged for this issue