Skip to content

No completions for generic object with string literal union types #54464

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
jprestidge-nex opened this issue May 31, 2023 · 4 comments
Closed

Comments

@jprestidge-nex
Copy link

jprestidge-nex commented May 31, 2023

Bug Report

🔎 Search Terms

  • Autocompletion, completions, missing, generics, object, string literals unions, etc.

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Generics

⏯ Playground Link

https://tsplay.dev/WGdLJw

💻 Code

type Test<
  T extends {
    example: "yes" | "no";
  }
> = T["example"];

const foo: Test<{ example: "" }> = "yes";
//                         ^^ <- No completions available here.
//                               As a string literal there should be concrete completions for "yes" | "no".

//                               The compiler does however recognize the correct type with type error:
//                               `Type '{ example: ""; }' does not satisfy the constraint '{ example: "yes" | "no"; }'.`

🙁 Actual behavior

There are no type completions hints for string literal unions inside generic objects.

🙂 Expected behavior

There should be type completion hints with the appropriate type variants. In the example above, with the completions should be yes and no.

@Andarist
Copy link
Contributor

Duplicate of #52898

@jprestidge-nex
Copy link
Author

That definitely is a worthy duplicate, sorry I couldn't find it before creating this 😞

Shall I close this issue?

@Andarist
Copy link
Contributor

I'd close it - since it so closely relates to that other issue.

@jprestidge-nex
Copy link
Author

Duplicate

@jprestidge-nex jprestidge-nex closed this as not planned Won't fix, can't repro, duplicate, stale May 31, 2023
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