Skip to content

Union between object and template string literal includes incorrect intellisense suggestions #51808

@Wundero

Description

@Wundero

Bug Report

When creating a union between a standard object type and a template string literal which includes generic values (e.g. `${number}/${number}`) causes the intellisense to suggest all functions in the String object, despite not actually being valid suggestions.

🔎 Search Terms

template string literal union object intellisense

🕗 Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about intellisense
  • I was unable to test this on prior versions because I cannot install them easily

⏯ Playground Link

Playground link with relevant code

💻 Code

type WorkingIntellisense = {
    key: string;
} | `string literal`;

const workingIntellisense: WorkingIntellisense = {
    key: 'value',
};

type BrokenIntellisense = {
    key: string;
} | `string literal ${string}`;

const brokenIntellisense: BrokenIntellisense = {
    key: 'value',
};

🙁 Actual behavior

The intellisense suggestion shows string functions.
image

🙂 Expected behavior

Intellisense should only show known properties.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: LS: Completion ListsThe issue relates to showing completion lists in an editorHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions