Closed
Description
π Search Terms
abstract constructor prototype type any
π Version & Regression Information
Latest version as of today.
β― Playground Link
π» Code
class A {}
type AConstructor = new() => A;
type AConstructorIntersection = (new() => A) & { prototype: A };
interface AConstructorRemedied {
new(): A;
prototype: A;
}
type AAbstractConstructor = abstract new() => A;
interface AImpossibleConstructor {
abstract new(): A; // error
prototype: A;
}
type _1 = (typeof A)['prototype']; // correct: A
type _2 = AConstructor['prototype']; // incorrect: any
type _3 = AConstructorIntersection['prototype']; // incorrect: any
type _4 = AConstructorRemedied['prototype']; // correct: A
type _5 = AAbstractConstructor['prototype']; // incorrect: any
π Actual behavior
There's no way of making the type of prototype
something other than any
, not even with an intersection.
π Expected behavior
A way to make the type of prototype
something other than any
. It seems that constructor types have a hidden prototype
of type any
. Shouldn't it be of type unknown
so that at least the intersection works? (or wouldn't it be better for it to be the same type as InstanceType
directly?)
Additional information about the issue
No response
Metadata
Metadata
Assignees
Labels
No labels