Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Template Literal Types Aren't Just for URLs

DEV Community·Gabriel Anhaia·29 days ago
#rEOvrZyp
Reading 0:00
15s threshold

Book: The TypeScript Type System — From Generics to DSL-Level Types Also by me: The TypeScript Library — the 5-book collection My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub Open any post about template literal types from the last three years. The example is a router. /users/:id , parse it, get back { id: string } . Type-safe Express. Type-safe Hono. Type-safe tRPC. The pattern is real and the routers are good, but the demo has eaten the feature. People read those posts and walk away thinking template literals are a URL trick. They are not. The router demo is the easiest example to make legible in a tutorial. The interesting uses live elsewhere, in the boring parts of a codebase where you build strings out of smaller strings and want the compiler to know what you built. Four of those places, with the code, and a note at the end on where the cost shows up.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More