Compose string literal types from smaller pieces.
Section: Type Operators
Use template literal types
typescript
typescript
type Method = "GET" | "POST";
type Route = "/users" | "/posts";
type Endpoint = `${Method} ${Route}`;Explanation
Template literal types are powerful for modeling event names, API routes, and CSS tokens.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Type Operators
Use indexed access types
Get a nested property type from another type.
Generic identity function
Use a type parameter for reusable function typing.