TLDR Dev · ARTICLES & TUTORIALS

HOW TO MAKE POSTMESSAGE TYPE-SAFE IN UNDER 350 BYTES

evilmartians.com9 min read

Summary from the TLDR Dev newsletter

typed-channel defines message names and payloads once so TypeScript can check both sides of a worker, iframe, or event-bus boundary. The core plus postMessage transport is 341 bytes with Brotli compression, while a separate request API adds typed replies and cancellation that propagates to the handler.