3 ms·
It does the job an expert human can do by reading the code without executing it. function willFail() { let x = null console.log(x.method()) } You can
by batmansmk 9y ago
It does the job an expert human can do by reading the code without executing it.
function willFail() {
let x = null
console.log(x.method())
}
You can read that this function will throw an exception all the time. But you may never execute this function in your test cases, so you won't see this problem in development but only too late, when a user hits the problem in prod.
It is called a static analysis and is 99.9% of the time faster to perform than executing every possible cases of your code. It doesn't catch exactly the same kind of issues either; so both are complementary.
- pseudosavant 9y agoUnfortunately it also thinks every function that uses a native browser variable/object (e.g. `screen` in my case) means it will fail because I never defined `screen` in my code. Other analysis tools like JSHint allow you to specify certain globals ($) or that you are in a browser environment with special annotations to handle this situation. I couldn't find anything in their documentation like that.
- mantoni 9y agoThe documentation has a list of supported browser features: https://javascript.studio/docs/browser-features https://javascript.studio/docs/browser-features Ideally all the browser APIs should be supported by the tool without the need to manually declare any globals.