In TypeScript, I would like the convenience of normal arithmetic operations:
const totalWeight = baseWeight + loadWeight
But I would like to prevent accidentally mixing units.
I tried something naive:
type Ounce = number;
type Gram = number;
const x: Ounce = 1;
const y: Gram = 2;
x + y;
... hoping it would give me a type error, but it didn't.
Is there a way to achieve this? Bonus credits if it could validate const s: Velocity = distance / time