Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 302
prmph Avatar asked Feb 21 '19 15:02

prmph


People also ask

How do I select TypeScript version in VS Code?

json file. The typescript. tsdk workspace setting only tells VS Code that a workspace version of TypeScript exists. To actually start using the workspace version for IntelliSense, you must run the TypeScript: Select TypeScript Version command and select the workspace version.


Video Answer


1 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."

like image 95
Shaun Luttin Avatar answered Oct 16 '22 02:10

Shaun Luttin