TypeScript Pays Off When Inventory Rules Get Weird

Published 2026-02-11 by Faraz Rahimi

SKU, pack qty, and location look like strings until they are not. Types catch the moment someone treats a case count like a unit count.

TypeScript Pays Off When Inventory Rules Get Weird

Tags: TypeScript, React, Inventory, Internal Tools, unlisted

I have shipped bugs where a pack of 12 was decremented as 12 locations. TypeScript does not make you smart. It makes that class of mixup louder at compile time if you model it.

I use branded types for SKU and bin. I do not use string for everything and hope.

Weird rules want a function with a name

"If it is a catch-weight item, do not use pack qty" should not be an if in a view. It should be a named function with tests. The UI calls it. The import job calls it. They cannot drift.

any is a pager

I allow any in glue I am deleting this week. I do not allow it on inventory writes. That sounds purist until you have credited the wrong unit at volume.

Original post: https://farazrahimi.com/posts/typescript-pays-off-when-inventory-rules-get-weird