Refreshing errors in VSC after installing typings

Viewed 2279

Using Visual Studio Code (v1.16.0), how do I refresh the errors in the Problems pane after installing Typescript typings for one of the required modules? (Edit: A similar problem exists for loading or updating dependent modules in the background.)

Rebuilding doesn't do it. I'm currently changing and re-saving each file to force VSC to regenerate errors and reflect the newly installed typings. I suppose I could instead close out the project and re-open it when there are a lot of files.

I'm kinda embarrassed to ask this question, because it seems so basic.

I need a solution that works with delegating builds to a gulp task. The gulp task uses the compiler options from tsconfig.json to be sure that VSC and the build report the same compiler errors. However, I've confirmed that the Problems pane does not update even when building via tsc: build - tsconfig.json.

1 Answers

I finally figured this out. Visual Studio Code offers a command for reloading the window and another for reloading the project. I found reloading the window to be sufficient. Upon reloading the window, the Problems pane re-evaluates for each open file.

Amazingly, VSC had not already mapped Command+R to anything. This combo refreshes the window in most browsers, so it is a perfect match here.

On a Mac, I mapped Command+R to reload the window in any context as follows:

  • Select the menu item Code|Preferences|Keyboard Shortcuts.
  • Click the keybindings.json link shown at the top of the window.
  • Add the following to keybindings.json and save the file:

    [ { "key": "cmd+r", "command": "workbench.action.reloadWindow" } ]

Now you can refresh the list of problems to reflect any background changes in installed typings or modules just by pressing Command+R.

See this VSC page on keybindings for more information or for how to do the equivalent on Windows. I'm happy to update this page with information on what works for Windows, after someone has successfully made the change. Hopefully Ctrl+R isn't already taken on Windows.

Alternatively, you can just open the command palette (Shift+Command+P) and type reloadWindow to refresh. Life's much easier with a keyboard shortcut, though.

UPDATE: I posted a feature request to make these keyboard bindings defaults in VSC.

Related