rinogo rinogo - 1 year ago 63
AngularJS Question

How to make VS Code aware of globals

My app compiles (transpiles) just fine, but VS Code is still showing a lot of errors:

enter image description here

In some of these cases (e.g.

), the problem is a global variable that is added via our inclusion of Angular/Ionic is not recognized.

How do I inform VS Code that these globals do, in fact, exist?

Answer Source

Inspired by another SO answer, I tried restarting VS Code. That fixed it. :/ (Update: Only temporarily)

Apparently, VS Code doesn't re-parse tsconfig.json after it has opened? I'm not sure of the exact internal logic of VS Code, but if you're having similar problems, you might try restarting the program.

In my particular case, I'm not really sure why this helped, since these globals are not defined in the type definitions but in the actual libraries... Regardless, it's clear that VS Code is a bit rough around the edges; whatever it was, restarting the app did it for me.

Update 6/27/16

Restarting VS Code just fixes the problem for a very short period of time. However, I have started using the "Insiders" build of VS Code, and the most recent build (updated today) seems to have fixed the problem (fingers crossed):

Tracker: https://github.com/Microsoft/vscode/issues/7253

Download VS Code Insider's Edition: https://code.visualstudio.com/insiders

If it helps, I'm using this version:

enter image description here