6 ms·
I think the "Quantity" type is a neat idea. I'm wondering how to implement that as a utility type in Typescript.
by noduerme 3y ago
I think the "Quantity" type is a neat idea. I'm wondering how to implement that as a utility type in Typescript.
- notarobot123 3y agoYou can use an intersectional type with a unique constraint to make something that behaves like a nominal type (see: https://www.typescriptlang.org/play#example/nominal-typing https://www.typescriptlang.org/play#example/nominal-typing)
- kroltan 3y agoIf you use a symbol as the brand key, you can even stack multiple different brands!