COOL WAYS TO TYPE
summary
Stripe.js uses the Flow static type checker to cut runtime errors and bundle bloat by applying three concrete techniques: exhaustive mixed refinements that force validation of unknown inputs, composable extractor functions plus a type-level map to validate many options without adding code size, and controlled use of trusted any casts to cross postMessage boundaries for iframes. Flow-typed wrappers also document DOM quirks like Firefox getComputedStyle returning null. Outcome: fewer runtime type errors, safer deploys for a library handling thousands of transactions per minute and 1–2 daily releases.
AI-written summary · about
