TypeScript Won't Let You Make That Call: Encoding Protocol State in the Type System
How to use phantom types and `this` parameters to turn illegal protocol transitions into compile-time errors instead of runtime bugs.
Every API client has a state machine hiding inside it. Handshake first. Authenticate second. Send data third. Close last. Break that order and you get runtime…