Communicating Intention with Functional TypeScript
summary
Concrete patterns and checks that change code reading into guarantees: use Result/Option discriminated unions to return success or error instead of throwing exceptions, name union members so the compiler enforces exhaustive handling, replace broad any with unknown over any and narrow with type guards, limit strings with literal unions so editors autocomplete status cases, and provide a deep immutable type via mapped generics so nested objects cannot be mutated at runtime thus reducing surprising runtime errors.
AI-written summary · about
chapters (13)
- 0:00Start
- 3:11TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.
- 5:33What is This Function Doing?
- 8:20Error Handling
- 8:37Avoiding Throwing Exceptions
- 16:29unknown
- 18:39function findByGenre(genre: string): Movie[]
- 21:20Make Invalid States Impossible to Represent
- 26:20What Happened With my Data?
- 26:30Immuta... what?
- 29:30Final Thoughts and Recap
- 30:16Be Honest About Your Function Signatures
- 30:47Limit the Scope of Strings








