Editor setup

Type-checked JavaScript in VS Code

  • Visual Studio Code
  • No extension needed

VS Code's JavaScript support is TypeScript's language service, so the hovers, completions and red squiggles in a .js file come from the same checker that tsc runs. It reads the nearest jsconfig.json or tsconfig.json and needs no extension for any of this.

Two changes make the editor agree with npm run lint: use the project's TypeScript version instead of the copy bundled with the editor, and run tsc as a task when you want errors from files you have not opened.

At a glance

EditorVisual Studio Code
What to installNo extension needed
What checks the codeTypeScript's own server (tsserver), started by VS Code's built-in JavaScript and TypeScript support
Where its TypeScript comes fromA copy bundled with the editor, or the project's typescript package when you pick Use Workspace Version
Readsjsconfig.json, tsconfig.json
How this page was checkedNot run in VS Code for this page. The settings and commands are from the VS Code documentation linked below; what the editor reports, the faded and struck-through suggestions included, comes from TypeScript's language service, which the site's tests run.

It finds your jsconfig.json

Open the folder that contains jsconfig.json (or a folder above it). Every .js file the config includes becomes part of one project, so types flow between files and the editor checks them with your compiler options. The Go to Project Configuration command in the Command Palette opens the config file the current file belongs to, which is the quickest way to check which one is in use.

Use the project's TypeScript version

VS Code ships with its own copy of TypeScript, which can be newer or older than the typescript package your lint script runs. It finds the copy in your project's node_modules by itself: open a JavaScript or TypeScript file, click the TypeScript version number in the status bar (or run TypeScript: Select TypeScript Version from the Command Palette) and choose Use Workspace Version.

To name the copy explicitly, set js/ts.tsdk.path to its lib folder in the workspace settings. Older VS Code releases call this setting typescript.tsdk.

.vscode/settings.json
{
  // the TypeScript in node_modules, the one npm run lint uses
  "js/ts.tsdk.path": "node_modules/typescript/lib"
}

Check files that belong to no project

For a one-off script with no jsconfig.json around it, either make // @ts-check its first line, or turn checking on for every loose JavaScript file in your user settings:

settings.json
{
  "js/ts.implicitProjectConfig.checkJs": true
}

List errors in files you have not opened

The editor reports errors for the files you have open. To see every error in the project in the Problems panel, run tsc as a task with the $tsc problem matcher, which reads tsc's output. --pretty false keeps the output in the plain one-line format.

.vscode/tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Check types",
      "type": "shell",
      "command": "npx tsc -p jsconfig.json --pretty false",
      "problemMatcher": "$tsc"
    }
  ]
}

What differs from tsc

The editor reports errors for the files you open, plus TypeScript's suggestions, which tsc never prints: names declared but never read are faded when noUnusedLocals is off, names marked @deprecated are struck through, and some lines get a hint with a quick fix (the light bulb). None of these fail npm run lint.

Make sure it matches tsc

After installing an @types package or editing jsconfig.json, the editor normally picks up the change by itself. If it does not, run TypeScript: Restart TS Server. If it still disagrees with npm run lint, compare the version number in the status bar with the output of npx tsc -v, and run Go to Project Configuration to see which config file the current file belongs to.

Gotchas

  • The bundled and the workspace TypeScript can disagree about new syntax and new checks. If CI runs tsc, use the workspace version so you see the same errors before you push.
  • With a jsconfig.json that does not set checkJs, .js files get completions and hovers but no type errors, except in files that start with // @ts-check.

Sources

Last reviewed 20 October 2026.