Template Literal Types are amazing for typing strings with patterns.
type Color = "red" | "blue";
type Quantity = "one" | "two";
type Item = `${Color}-${Quantity}`;
// Type is "red-one" | "red-two" | "blue-one" | "blue-two"
This is incredibly useful for typing CSS classes, event names, or any string-based API contract.
Discover more from C4: Container, Code, Cloud & Context
Subscribe to get the latest posts sent to your email.