microsoft / microsoft/TypeScript
Inference from annotated parameters of context-sensitive functions is order dependent
Open
Nobody has claimed this yet.
Bug
Domain: check: Type Inference
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
inference annotated parameters context sensitive order
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
declare function test<T, A, B>(obj: {
ctx: T;
a: (a: A, ctx: T) => void;
b: (b: B, ctx: T, a: A) => void;
}): void;
test({
ctx: 'foo',
a: (a: string, ctx) => {},
b: (b: string, ctx, a) => {},
});
test({
ctx: 'foo',
b: (b: string, ctx, a) => {},
a: (a: string, ctx) => {},
});
🙁 Actual behavior
The second call doesn't infer properly
🙂 Expected behavior
I'd expect the second call to be inferred as good as the first one
Additional information about the issue
related to https://github.com/microsoft/TypeScript/issues/47599
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
Reproduce the two calls in the linked TypeScript Playground and compare their inference behavior, then read the related issue #47599 for context. Investigate the type inference and contextual typing paths involved; done means the second object-property order infers as successfully as the first without regressing the existing example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100