News for hackers. Stuff that matters.
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
Re:TypeScript: Branded Types by kevincox on Thursday April 25, 2024 @04:31PM (#40162629)
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).