Re:JavaScript for squares: The incredible rise of TypeScript
by slackingoff2017 on Wednesday July 26, 2017 @01:12AM
(#14853803)
IMO the static analysis that becomes possible from using types is more useful than types themselves.
My favorite JS gotcha is the number of special values a variable can take on. NaN, Undefined, null, Infinity, -Infinity, maybe more? Also the fact that arrays and objects are always truthy. Honorable mention for the seemingly random results of concatenating strings. I'm tired of getting burned by these design flaws and if it takes strong typing to be protected from them than so be it.
That said: as my ES2017 app gets more complex, a little type safety could be useful. I think it might catch more stuff - eg, earlier this week I tried to use a Promise (because I forgot an 'await') and then got a bunch of NaNs on invoices (the unit tests had the await, so passed, the route didn't).
Renaming something to .ts and adding a quick compilation step doesn't seem like a big deal and would catch that error. Typescript also has a MASSIVE amount of community support around it. So yeah: still don't believe 'typing is safety' but will likely end up using TypeScript by the end of the year.