Microsoft/TypeScript
View on GitHubInstantiation expressions don't reject incompatible signatures in situations with mixed call and construct signatures
Open
#59,319 opened on Jul 17, 2024
Domain: check: Type InferenceHelp WantedPossible Improvement
Repository metrics
- Stars
- (48,455 stars)
- PR merge metrics
- (Avg merge 6d 17h) (9 merged PRs in 30d)
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