Skip to content

NoInfer breaks discriminate union autocompleteΒ #60253

@Harpush

Description

@Harpush

πŸ”Ž 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions