Advantages of opaque types over value objects

from blog nickb.dev, | ↗ original
Most should be in agreement that the following signature is in bad taste: type MyObject = { price: number; } Is the price in dollars, cents, or is it even some other currency? What’s protecting another developer (including the future self) from footguns? // Mixing up dollars and cents const discountDollars = 2; const productCents = 10000; const...