Skip to content

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

@jprestidge-nex

Description

@jprestidge-nex

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions