Jan-17, 2025 · 1min
change languageLearn how to use template literal types in TypeScript, create dynamic type definitions through string templates, and improve type safety and code readability
Template Literal Types is a type in TypeScript, it allows you to create a string type that can contain variables.
type World = 'world'
type Greeting = `hello ${World}`
type EmailLocaleIDs = 'welcome_email' | 'email_heading'
type FooterLocaleIDs = 'footer_title' | 'footer_sendoff'
type AllLocaleIDs = `${EmailLocaleIDs | FooterLocaleIDs}_id`