Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Phantom Types in TypeScript: Stop Mixing Kilograms and Pounds at Compile Time

DEV Community·Gabriel Anhaia·30 days ago
#1si8Z4TJ
Reading 0:00
15s threshold

Book: The TypeScript Type System Also by me: The TypeScript Library — the 5-book collection My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub A warehouse integration sends a parcel weight to a label printer. The shipping API accepts kilograms. The product catalog stores pounds, because the catalog was scraped from a US supplier ten years ago and nobody renamed the column. Somewhere in the middle, a backend engineer writes total = boxWeight + itemWeight and ships it. The label prints 2.4 kg for a parcel that actually weighs five and a half kilos. The carrier weighs it on intake, flags every package on the truck, and the support inbox starts filling up before lunch. The story is older than computers. NASA's Mars Climate Orbiter was lost in 1999 because one piece of ground software output pound-force-seconds (lbf·s) while the spacecraft expected newton-seconds (N·s) .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More