Skip to content

template literal types starting with ${string} don't work when the string has more than 1 characterΒ #42903

Closed
@DetachHead

Description

@DetachHead

Bug Report Suggestion

πŸ”Ž Search Terms

template literal types string

πŸ•— Version & Regression Information

4.3.0-dev.20210221

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about trmplate literal types

⏯ Playground Link

https://www.typescriptlang.org/play?ts=4.3.0-dev.20210221#code/MYewdgzgLgBAZiEAuGADAJAb2gJwJZgDmAvlmAK4C2ARgKY7GowC8MA5AIYCMATAMxsYAeiFgQMejhA4AsAChQkWNQ44UGbFHxFSmCjXqMW7BCF4DhQgCoBPAA612AIlPmngvBBhjYHCBDxCMA5qABtHKHEoe0c2DVwCEjIqOgZUNgA6IA

πŸ’» Code

const foo: `${string}${number}` = 'a123' //no error
const bar: `${string}${number}` = 'foo123' //Type '"foo123"' is not assignable to type '`${string}${number}`'.

πŸ™ Actual behavior

Type '"foo123"' is not assignable to type '`${string}${number}`'

πŸ™‚ Expected behavior

no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions