TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

NoInfer breaks discriminate union autocomplete

Open Harpush opened this issue 1 year ago • 0 comments

🔎 Search Terms

no infer discriminate union

🕗 Version & Regression Information

Tested on version 5.6.3

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgILIN4ChnLATwAcIAuZAcjnIBodkA3OAGwFdTkBnMKUAcwG4sAXyxZQkWIhQAhTHQLEy5AEY06HYAC92IFgFtl0QSKwKUAVRDAA9iGQBeNMgA+yaYKwwWIBGBt3EJEIwAB4AFWQIAA9IEAATDmRLfwA+AApvfzIAOWsASRAYaHCUgEo5YVFAiGC0jDMlKiFSoA

💻 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): Image

🙂 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

Harpush avatar Oct 17 '24 08:10 Harpush