Skip to content

Cannot define a matching template literal type to a defined template literal  #43143

Description

Bug Report

🔎 Search Terms

string, template, literal, type

🕗 Version & Regression Information

This is the behavior in every version I tried, including Nightly

⏯ Playground Link

Playground link with relevant code

💻 Code

function getCardTitle(title: string): `test-${string}` {
    return `test-${title}`;
}

🙁 Actual behavior

TS infers the type string for the returned string, instead of the templated type.

🙂 Expected behavior

No error!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions