Skip to content

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

Closed
@EdwardDrapkin

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

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions