Skip to content

Wrong type when creating an instance from a type which inherits from a generic class #6783

@stephanedr

Description

@stephanedr

The following code is fine:

function create<T>(ctor: { new (): T }) {
    return new ctor();
}

class A { }
class B<T> extends A { }
let b = create(B); // b: B<any> --> OK

But if A is generic, the type is not correct.

class A<T> { }
class B<T> extends A<T> { }
let b = create(B); // b: A<any> --> Should be B<any>

Sorry if this has already been reported.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions