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
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 .
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.
When you have opened a typescript file, click on typescript version on the right bottom corner of vscode, and select Use Workspace Version
.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With