-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone
Description
π Search Terms
instantiation expression signature applicable incompatible call construct class
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
class Foo {}
type Test = {
<T extends number>(arg: T): T;
new <T extends string>(arg: T): Foo;
};
declare const test: Test;
const intantiated = test<"">;π Actual behavior
An error gets reported:
Type 'string' does not satisfy the constraint 'number'.(2344)
And the final type of instantiated is computed as:
const intantiated: {
<T extends number>(arg: T): T;
new (arg: ""): Foo;
}π Expected behavior
I'm not 100% sure but it feels like this type could be successfully instantiated to { new (arg: ""): Foo; }. This is the only signature that matches the given type arguments.
Additional information about the issue
No response
backbone87
Metadata
Metadata
Assignees
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionHelp WantedYou can do thisYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some casesThe current behavior isn't wrong, but it's possible to see that it might be better in some cases