9 ms·
So basically the same as type safety through constructor constraints and instanceof... Just a bit cleaner (maybe) If you could extend primitives in Typescript,
by danLugo 9y ago
So basically the same as type safety through constructor constraints and instanceof... Just a bit cleaner (maybe)
If you could extend primitives in Typescript, you'd have "amount extends Number" and put the necessary constraints in the constructor and your operator overloads. Maybe some or all of it could be translated to runtime checks in javascript.