News for hackers. Stuff that matters.
Re:TypeScript: Branded Types by spankalee on Wednesday April 24, 2024 @10:34PM (#40152689)
As much as I love branding, I would be hesitant to use it for critical math and where you might want to inspect the type at runtime as with money.

Branding is easily circumvented, so it's best as a developer hint that helps document APIs and alerts us to common mistakes as an incremental improvement over primitives.

For money and similar I would use objects and a custom math library.

Re:TypeScript: Branded Types by epolanski on Thursday April 25, 2024 @04:17AM (#40154842)
You can parse before brand thus enhance and enforce runtime correctness.