3 ms·
I'm pretty sure all weak typing warts basically stem from equality checks with ==/===. If you use === all the time you'll never run into them. TS has optionals
by johnfn 9y ago
I'm pretty sure all weak typing warts basically stem from equality checks with ==/===. If you use === all the time you'll never run into them.
TS has optionals so undefined is not an issue.
The rest is valid.
- legulere 9y agoThere are also some JavaScript functions like isNaN that also do type coercion and of course +. How is this handled in typescript?
- nycdotnet 9y agoIn a word, "correctly". The result of an expression with + or isNaN() will be of whatever type the JS spec says it should be. This is one of the less frequently touted, but more useful aspects of TypeScript - the lib.d.ts file acts as a partner to explain to you how the built-in JS type system actually works without you having to memorize or look up everything in docs.
- bcherny 9y agoBy optionals I assume you mean null and undefined types, not optionals in the Scala or Swift sense.