microsoft / microsoft/TypeScript
Instantiation expressions don't reject incompatible signatures in situations with mixed call and construct signatures
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.4k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided example in the linked TypeScript Playground and compare the reported error and resulting type with the expected behavior. Trace how instantiation expressions handle mixed call and construct signatures, then add a regression test for the example and verify that only the compatible construct signature remains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100