News for hackers. Stuff that matters.
Re:TypeScript 5.0 by TOGoS on Thursday March 16, 2023 @04:53PM (#35188404)
Addendum to my nominal types: For the 'fake' nominal types (you can't put a symbol on a number!) I like to make those fields optional, which makes the type less of a lie. "If this number did have a [unit symbol] property, the value would be 'USD'". That will still prevent accidental USD <-> CAD conversion, but allows converting to/from regular numbers without explicit casting.

A pile of thoughts on the subject from back when I first came up with it: http://www.nuke24.net/plog/32.html

Re:TypeScript 5.0 by triyambakam on Friday March 17, 2023 @02:30AM (#35193911)
Very cool
Re:TypeScript 5.0 by liminal on Friday March 17, 2023 @12:37PM (#35199387)
This is really great. I once spent a little time thinking about how to better represent RDF in Type/Javascript. These approaches seem like a good direction to go in. Would love to see these ideas developed further.
Re:TypeScript 5.0 by isleyaardvark on Sunday March 19, 2023 @11:30AM (#35219949)
I’ve seen several TS users describe that approach as “branding” (or “flavoring” if it is optional).