Re:TypeScript: Branded Types
by kristiandupont on Wednesday April 24, 2024 @02:04PM
(#40147668)
Yes you can, it works just the same :-)
[ Parent
| on HN ]
Sorry, with the Symbol? How does it work?
You don't even need the symbol. If you want the simplest thing that will work:
type Velocity = number & { BRAND: "Velocity" }
type Distance = number & { BRAND: "Distance" }
var x = 100 as Distance