Brand your types - Join me in the fight against weakly typed codebases!
summary
Claim: using branded types in TypeScript makes primitives like string and number carry intent so illegal states become unrepresentable. Concrete tools: TypeScript branded type syntax, type guards, and libraries named SAD and IOTS. Example: GraphQL article payloads are parsed at the edges into RelativeURL and AbsoluteURL brands so navigation and link code no longer revalidate every case. Outcome: zero runtime cost, compiler catches swapped username/password mistakes, tests simplify and the codebase stops getting polluted.
AI-written summary · about
chapters (8)
- 0:00Branded types intro
- 1:37Primitive types problems
- 4:09Compile-time safety with branded types
- 6:18Fixing swapped arguments
- 7:43Parsing vs validating data
- 9:31Real-world branded types example
- 13:24Key takeaways
- 14:48Branded numbers examples
related talks
22mThink you know TypeScript? Think again.
40mTypeScript and Your Codebase: They Deserve Each Other!
47mRock-Solid Components with TypeScript and GraphQL
27mMatthew Gerstman - TypeScript: Seeing Past the Hype
01h 01mDeconstructing TypeScript’s Type System
30mSwipe Left, Uncaught TypeError Learning to Love Type Systems
11mThe Joy of Typescript
21mThe long-tail of type safety
