Skip to content

Problem with declaration file generated from generic extended function #17840

Closed
@nayish

Description

@nayish

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.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: Declaration EmitThe issue relates to the emission of d.ts filesFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions