ML
Topic

TypeScript

TypeScript patterns that prevent real bugs — discriminated unions, branded types, parse-don't-validate, and the type-level idioms that turn a refactor from a leap of faith into a compile-time confirmation.

5 articles · updated regularly

TypeScript
Jun 27, 20268 min

The IDs That Came Back Wrong: JavaScript's 2^53 Integer Ceiling

A handful of users reported that clicking a notification took them to the wrong record. The IDs were off by one or two at the very end, always on the biggest accounts. The backend was sending the correct 64-bit ID every time. Our frontend was quietly rounding it the instant it parsed the JSON, because in JavaScript every number is a float.

TypeScriptJavaScript
Read
TypeScript
May 10, 20267 min

Branded Types for Domain Safety

UserId, OrderId, Email — all of them strings to the compiler, all of them disasters when accidentally swapped. Branded types are five lines of code that prevent the whole class.

TypeScriptPatterns
Read