How to make Visual Studio Code check entire project for errors?

VS Code (v1.44) has an experimental feature, that allows project wide error reporting in TS. Try it out:

// put this line in settings.json
"typescript.tsserver.experimental.enableProjectDiagnostics": true

Figured it out. Note this answer is specific to TypeScript, which is what I am using. Here it is:

Make sure typescript is installed globally (I just had mine installed locally apparently): npm install -g typescript

Then in VS Code press Shift+Ctrl+B. If you don't have a task runner set up it will ask what you want. I selected typescript and the tasks.json file will look like this:

{
    "version": "0.1.0",
    "command": "tsc",
    "isShellCommand": true,
    "args": ["-p", "."],
    "showOutput": "silent",
    "problemMatcher": "$tsc"
}

Then pressing Shift+Ctrl+B (or Shift+Command+B in macOS) will check the entire project for problems and they will be reported in your "problems" panel.


For the most recent version of tasks.json this is the correct json, following deprecations in version 1.14. Create this as /.vscode/tasks.json

{
    "version": "2.0.0",
    "command": "tsc",
    "type": "shell",
    "args": [
        "-p",
        "."
    ],
    "presentation": {
        "reveal": "silent"
    },
    "problemMatcher": "$tsc"
}

If you don't want to install TypeScript globally, you can do the following:

  1. Install TypeScript locally on the project, that is yarn add --dev typescript or npm install --save-dev typescript.

  2. Add a check-types run script to ./package.json. --noEmit means that the compiler will won't generate any JavaScript files.

{
  "scripts": {
    "check-types": "tsc --noEmit"
  }
}
  1. Let VSCode know about the run script in /.vscode/tasks.json.
{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "npm",
      "script": "check-types",
      "problemMatcher": [
        "$tsc"
      ]
    }
  ]
}
  1. To run the tasks hit the F1 key and select 'Run Task', and then 'npm: check-types'.

  2. If you add the following lines to the task, pressing Ctrl+B will run it.

    "group": { "kind": "build", "isDefault": true }