§ GARDEN · TYPESCRIPT · CLASS OPEN
NODE FILE · ENTRY
Type-Level Programming in TypeScript
FILED UNDER · TYPESCRIPT
①Read
②Meta
Conditional types, mapped types, and template literal types — programming the type checker itself.
TypeScript's type system is Turing-complete. You can write recursive types, conditional branches, string manipulation, and arithmetic — all evaluated at compile time. This isn't a parlor trick. It's how libraries like Zod, tRPC, and Prisma provide their magical developer experience.
Conditional Types as If Statements
The syntax T extends U ? X : Y is a ternary at the type level. When combined with infer, you can extract parts of types — like pulling the return type from a function signature or unwrapping a promise. Stack these and you can derive complex types from simple inputs.
DTNRWORKSHOP ARMAMENTSSN 2012.OTT.0176