Re:TypeScript: Branded Types
by dimitrisnl on Wednesday April 24, 2024 @03:07PM
(#40148256)
Selfish plug about the same topic https://dnlytras.com/blog/nominal-types
[ Parent
| on HN ]
I also wrote something like this and came up with something similar to yours: https://kevincox.ca/2023/03/21/lying-to-typescript/#summary
However I just inlined the "tag". Also like yours but unlike OP there is no runtime tag. Which can be a pro (no extra code) or a con (can't do runtime checks).