Skip to content
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

Declaration file not generated properly when extending from a function that returns a constructor signature. #15572

Closed
rzvc opened this issue May 4, 2017 · 0 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@rzvc
Copy link

rzvc commented May 4, 2017

TypeScript Version: 2.4.0-dev.20170503

Code

class SomeClass
{
}

interface IFace
{
}

class Derived extends getClass<IFace>()
{
}

function getClass<T>() : new() => T
{
	return SomeClass as any;
}

To compile: tsc test.ts --declaration

Expected output:

declare class SomeClass {
}
interface IFace {
}
declare class Derived extends getClass<IFace>() {
}
declare function getClass<T>(): new () => T;

Actual output:

declare class SomeClass {
}
interface IFace {
}
declare class Derived extends IFace {
}
declare function getClass<T>(): new () => T;

The problem here is that IFace is not a class, so it can't be extended, which is why the original declaration should be used instead. If it was a class, the output would be perfectly valid.

@mhegazy mhegazy added the Bug A bug in TypeScript label May 4, 2017
@mhegazy mhegazy added this to the TypeScript 2.4 milestone May 4, 2017
@sandersn sandersn added the Fixed A PR has been merged for this issue label May 5, 2017
@sandersn sandersn closed this as completed May 5, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants