4 ms·
I encourage you to convert some of your JS code. In my experience converting something like 10k lines, this is absolutely true. I convert using strictest compi
by slackingoff2017 9y ago
I encourage you to convert some of your JS code. In my experience converting something like 10k lines, this is absolutely true.
I convert using strictest compile rules + TsLint with most rules on. In those 10kish lines I found hundreds of potential bugs. I'm sure at least a third were real.
The biggest culprits in our codebase were classic type errors and improper use of truthy/falsey. Adding types enables a ton of static analysis like identification of broken conditional statements. I found over 100 if statements that were always true/false or otherwise ineffective.
- tonyedgecombe 9y ago"I found over 100 if statements that were always true/false or otherwise ineffective." I'm not sure whether that shows how good Typescript is or how bad Javascript is.
- slackingoff2017 9y agoMostly the latter. With strict type checking enabled TsLint will warn you about impossible conditionals. You can go a step farther and force conditionals to return boolean true/false. This disables JavaScript's "truth/falsey" but prevents a whole class of errors caused by questionable design decisions... Like empty arrays being truthy.