Template Literal Types: String Patterns
Combine string unions into pattern types.
Welcome
Template literal types use backtick syntax at the type level to construct string types from combinations of other string types.
Basic Template Literal Type
Combine string literal types with template syntax.
type Greeting = `Hello, ${string}`;
const g: Greeting = 'Hello, World'; // OK
// const bad: Greeting = 'Hi there'; // ErrorAll lessons in this course
- Mapped Types: Transforming Object Types
- Modifiers in Mapped Types: readonly and ?
- Template Literal Types: String Patterns
- Key Remapping with as in Mapped Types