Unexpected Monad. Is Safe Error Handling Possible in JS/TS?
summary
Claim: JavaScript/TypeScript can enforce typed exception flow by replacing try/catch with an Either/Result monad plus small glue to interoperate with promises and RxJS. Implementation uses TypeScript signatures, strict mode, custom Rx operators (mapEither, tapEither) and container types; a closed‑source Angular 8 app runs this in production since 2019. Outcome: compilation errors surface unhandled exception variants and handlers carry concrete types, reducing certain classes of bugs; tradeoffs are boilerplate, third‑party integration and custom lint rules.
AI-written summary · about
chapters (10)
- 0:00Unexpected Monad intro
- 2:12Error handling checklist
- 5:47Try-catch improvements
- 10:49Multiple return values
- 13:40Container-based errors
- 17:42Monads as utilities
- 20:59Monads in Angular
- 24:42Why try-catch dominates
- 26:52Monads without PhD
- 27:37Q&A
related talks
31mProgramming Safely in an Uncertain World
31mMONADS - CODING FUNCTIONALLY
57mTypeScript : More than just another JS transpiler
24mTypeScript for JavaScripties
20mUnhandled rejections and other awaited promise tales
41mNext Generation Asynchronous Patterns in JavaScript
28mError handling: doing it right!
28mEctype - bringing type safety (and more!) to vanilla JavaScript
