Skip to content

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

Closed

Description

@usernamehw

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.

Activity

  1. jack-williams commented on Nov 29, 2018

    @jack-williams
    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.

  2. usernamehw commented on Nov 29, 2018

    @usernamehw
    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
  3. weswigham commented on Nov 30, 2018

    @weswigham
    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.

  4. usernamehw commented on Nov 30, 2018

    @usernamehw
    Author

    Can this be implemented as a TS plugin then?

    • Type checking should stay as it is
    • Editor autocomplete should have these items
  5. weswigham commented on Nov 30, 2018

    @weswigham
    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.

  6. typescript-bot commented on Dec 12, 2018

    @typescript-bot
    Contributor

    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.

  7. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions