How to force VSCode to use locally installed TypeScript

后端 未结 2 1025
情话喂你
情话喂你 2021-01-12 06:01

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 glob

2条回答
  •  闹比i
    闹比i (楼主)
    2021-01-12 06:32

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

提交回复
热议问题