How to Force Vscode to Use Locally Installed Typescript

Is there a way to force Visual Studio Code to use the TypeScript installed locally in a JS project (instead of the version bundled with VSCode, or the version installed globally) for type checking when editing that project?

4

2 Answers

I assume that you have installed TypeScript in the myProject directory.

cd myProject
npm install --save-dev typescript

If you have already done that, then add a .vscode/ directory with a settings.json file that specifies the TypeScript SDK to use:

{
    "typescript.tsdk": "node_modules\\typescript\\lib"
}

This is the final directory structure:

myProject
  .vscode
    settings.json
  node_modules
    typescript
      lib

Important: make sure that you open VSCode in the myProject directory!

The VS Code documentation calls this "using the workspace version of TypeScript."

7

Shaun Luttins answer worked for me except for one detail: Using Version 1.31.1 of Visual Studio Code file settings.json only works if placed directly in the root folder of the workspace, not in folder .vscode.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest