microsoft / microsoft/TypeScript
NoInfer breaks discriminate union autocomplete
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
no infer discriminate union
🕗 Version & Regression Information
Tested on version 5.6.3
⏯ Playground Link
💻 Code
interface A {
type: 'a',
value: string;
}
interface B {
type: 'b',
size: number;
}
type Union = A | B;
function accept<T extends Union>(union: NoInfer<T>) {
}
accept({type: 'a'})
🙁 Actual behavior
When trying to autocomplete after writing type a the autocomplete doesn't work (but the result does get type checked):
🙂 Expected behavior
Even with NoInfer it should autocomplete the other properties of the "inferred" discriminate union case as it correctly type checks it if written wrong.
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 with the linked TypeScript Playground reproduction and compare autocomplete behavior with the existing type-checking result for NoInfer and a discriminated union. Done means the remaining properties of the selected union case are offered after entering type 'a', while incorrect values continue to be rejected.
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
- Clearly specified
- Newbie friendliness
- 45/100