Skip to content

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

Closed

Description

@rzvc

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugFixed

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions