Enhanced safety with types
summary
TypeScript code shows how to make impossible states impossible by modeling state instead of using loose booleans: an editable union replaces an editing flag plus buffer so buffer exists only when editing, preventing invalid paths at compile time. For async loads a RemoteData type (NotAsked, Loading, Success, Failure) replaces three booleans — three booleans -> eight states but only four valid — so data only exists in Success. Also mentions decoders/encoders for parsing external JSON.
AI-written summary · about
chapters (6)
- 0:00Start
- 3:15Type Error
- 9:11Union Type
- 31:11Debugging
- 34:26Impact of Failure in Production
- 38:53How Would You Handle Data from Outside World
related talks
21mThe long-tail of type safety
21mThe long-tail of type safety
25mLeveraging (algebraic data) types to make your UI rock solid
01h 01mDeconstructing TypeScript’s Type System
25mLeveraging (algebraic data) types to make your UI rock solid
20mTaming UI complexity with Typed State Machines
24mTypeScript for JavaScripties
22mThink you know TypeScript? Think again.
