Skip to content
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

AutoComplete for string literal types fails when the type union contains a generic <string> #30085

Closed
bd82 opened this issue Feb 25, 2019 · 2 comments

Comments

@bd82
Copy link

bd82 commented Feb 25, 2019

Description:

When a string literal type union also includes the general string type.
content assists stops working in VSCode (and the playground).

Code to reproduce the issue:

  function define(deps: depItemOrString[], Function) {}
  type depItemOrString = string | "ima/aba/bamba" | "winter/is/coming" | "there/can/be/only/one";

  // Intelli-sense for the string literals does **not** work here.
  define(["bamba"], () => {})

  function define2(deps: depItem[], Function) {}
  type depItem =  "ima/aba/bamba" | "winter/is/coming" | "there/can/be/only/one";

  // Everything works perfectly when the literal type union does not include a "general" string type.
  define2(["ima/aba/bamba"], () => {})

Try this code in the Playground

Expected Behavior

I would expect that in both function (define and define2) auto-complete suggestion
would be provided based on the literal string union type.

Actual Behavior

The auto-complete suggestions are only provided for a "pure" string literal type.
Meaning one that does not include a "generic" string as well:

type pureLiteralStringType = "a" | "b" | "c"
type impureLiteralStringType = string | "a" | "b" | "c"
@bd82 bd82 changed the title AutoComplete for string literal types fails when the type union contains a generic "string" AutoComplete for string literal types fails when the type union contains a generic <string> Feb 25, 2019
@jack-williams
Copy link
Collaborator

Duplicate of #29729

@bd82
Copy link
Author

bd82 commented Feb 26, 2019

Oh sorry I will close this.

@bd82 bd82 closed this as completed Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants