Template literal types tạo string types từ combinations.
- Kết hợp với union cực kỳ mạnh cho type-safe event names, CSS properties, API endpoints.
- Intrinsic types: Uppercase, Lowercase, Capitalize, Uncapitalize.
typescript
type EventName = `on${Capitalize<string>}`;
type Side = 'top' | 'bottom' | 'left' | 'right';
type Padding = `padding-${Side}`; // "padding-top" | "padding-bottom" | ...
type Handlers = { [K in EventName]?: () => void };
// Dùng trong event bus, styled-components, API path generation