Search code examples
javascriptidewebstorm

Why do JavaScript IDEs not denote errors as in compiled language IDEs?


I am curious why, in almost every JavaScript IDEs (like in WebStorm), unresolved variables or types (and any other errors) are just underlined with a light grey line as you can see in the picture.

As opposed to this, compiled language IDEs (like CLion) indicates errors with a clearly seen red line showing, that there is something important to recognize. I know notations can be modified, but I don't understand the logic behind the default notation.

I also don't know why JavaScript IDEs permit you to run the project, if there are errors. I suppose, because JS is an interpreted language?

WebStorm indicates errors with grey line


Solution

  • Javascript variables are looked up at runtime. It's entirely possible that your HTML page includes some other 3rd party script, which sets a global variable, which your code then accesses at runtime. So even though it looks like the variable isn't defined because you didn't define it, it's entirely possible that the variable will exist at runtime and the IDE simply isn't able to trace that statically.