Skip to content

Can't autocomplete list of strings when union string | string is present #28743

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
usernamehw opened this issue Nov 29, 2018 · 6 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@usernamehw
Copy link

usernamehw commented Nov 29, 2018

TypeScript Version: 3.2.1-dev.20181127

Search Terms:

Tried Domain: Completion Lists github label, didn't find a duplicate, there is probably one somewhere...

Code

type ListOrString = 'one' | 'two' | string;
const str: ListOrString = '';// Trigger autocomplete

Expected behavior:

Autocomplete shows

  • one
  • two

Actual behavior:

Only word suggestions.

@jack-williams
Copy link
Collaborator

Duplicate of #12687

The union type is simplified into a normal-form via subtype reduction; hovering over ListOrString will only show the supertype string.

@usernamehw
Copy link
Author

So...

  • it was working at some point
  • it was reported and accepted to be a bug
  • it was given an explanation new is always better

The type "foo" | "bar" | string is equivalent to the string type and now gets simplified early on. So all we see when querying the type checker for the type of x is string. So, this can't be fixed.

  • the issue got closed and locked so nobody could find it

@weswigham
Copy link
Member

I've tagged the old issue with a domain label for future use, but it predates when we used domain labels, which is why we didn't have one on it. And most old issues without activity are closed/locked.

@weswigham weswigham added the Duplicate An existing issue was already created label Nov 30, 2018
@usernamehw
Copy link
Author

Can this be implemented as a TS plugin then?

  • Type checking should stay as it is
  • Editor autocomplete should have these items

@weswigham
Copy link
Member

We don't really have plugins - sans editor-wide ls plugins that wrap the entire ls. They can do anything, since they just wrap and intercept the LS, it's just not always easy.

@typescript-bot
Copy link
Collaborator

This issue has been marked as a duplicate and has seen no activity in the last day. It has been closed automatic house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants