Skip to content

Problem with declaration file generated from generic extended function #17840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nayish opened this issue Aug 16, 2017 · 1 comment
Closed

Problem with declaration file generated from generic extended function #17840

nayish opened this issue Aug 16, 2017 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue

Comments

@nayish
Copy link

nayish commented Aug 16, 2017

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.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Aug 16, 2017
@mhegazy mhegazy added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Sep 1, 2017
@mhegazy mhegazy modified the milestone: TypeScript 2.6 Sep 1, 2017
@mhegazy mhegazy modified the milestones: TypeScript 2.6, TypeScript 2.7 Oct 9, 2017
@weswigham
Copy link
Member

This is now an error, as per #17922

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 11, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants