Skip to content

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

Description

@EdwardDrapkin

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!

Metadata

Metadata

Assignees

Labels

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

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions