Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use TypeScript version defined in settings.json by default in VSCode?

Requirement: When opening TypeScript files in VSCode, use the typescript version from node_modules instead of VSCode's TypeScript version

In .vscode/settings.json, I added the following settings as defined in the documentation:

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

However, VSCode still uses it's typescript version by default. I've reproduced the issue in vscode-typescript-default-version repository.

What needs to be done to use typescript version from node_modules by default when opening TypeScript files in VSCode?

Trivikram

like image 721
Trivikram Avatar asked Apr 20 '18 20:04

Trivikram


People also ask

How do I change the TypeScript version in Visual Studio code?

Tip: To get a specific TypeScript version, specify @version during npm install. For example, for TypeScript 3.6. 0, you would use npm install --save-dev [email protected] . To preview the next version of TypeScript, run npm install --save-dev typescript@next .

How do I change Vscode default settings in JSON?

You can open the settings.json file with the Preferences: Open Settings (JSON) command in the Command Palette (Ctrl+Shift+P). Once the file is open in an editor, delete everything between the two curly braces {} , save the file, and VS Code will go back to using the default values.


1 Answers

When you have opened a typescript file, click on typescript version on the right bottom corner of vscode, and select Use Workspace Version.

enter image description here

If you need this configuration as default to all typescript files on vscode put the configuration on "User Settings" (ctrl+,).

"typescript.tsdk": "node_modules/typescript/lib"

In my case I have this file in ~/.config/Code/User. If you open a file on a directory whithout node_modules/typesript/lib a warning is shown:

The path /home/jahuuar/test/node_modules/typescript/lib doesn't point to a valid tsserver install. Falling back to bundled TypeScript version.

like image 148
4ndt3s Avatar answered Nov 15 '22 04:11

4ndt3s