Skip to content

Probably easy to fix: Inline static template string values even when there are non-static values too #4301

@L3P3

Description

@L3P3

What works fine

const name = 'Alice';
alert(`Hello, ${name}!`);

produces:

alert("Hello, Alice!");

What fails

const name = 'Alice';
alert(`Hello, ${name}! ${navigator.userAgent}`);

produces:

alert(`Hello, ${"Alice"}! ${navigator.userAgent}`);

but should produce:

alert(`Hello, Alice! ${navigator.userAgent}`);

even better would be to break up templates in such cases (when the dynamic value is at start or end):

alert("Hello, Alice! "+navigator.userAgent);

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