Can TypeScript be updated automatically?
VS Code ships with a recent stable version of TypeScript.
– from VS Code docs
This means there’s no way to automatically upgrade the TypeScript version used by VS Code. You can however override the TypeScript version VS Code uses by modifying either the user settings or the workspace settings.
What TypeScript version is VS Code using?
When you open a TypeScript file, VS Code should display the TypeScript version in the status bar at the bottom right of the screen:
In newer versions (or when the status bar is crowded?) you may have to hover the mouse over the {}
next to TypeScript
to see a pop-up with the information:
Changing the global TypeScript version
- Install the desired TypeScript version globally, for example
npm install -g [email protected]
- Open VS Code User Settings (F1 >
Open User Settings
) - Update/Insert
"typescript.tsdk": "{your_global_npm_path}/typescript/lib"
you can find out {your_global_npm_path} by typing npm root -g
Now all of the projects you open with VS Code will use this TypeScript version, unless of course there is a workspace setting that overrides this.
Changing the local TypeScript version
-
Open the project in VS Code
-
Install the desired TypeScript version locally, for example
npm install --save-dev [email protected]
The
--save-dev
will update your project’spackage.json
, adding the TypeScript version you installed as adevDependency
. -
Open VS Code Workspace Settings (F1 >
Open Workspace Settings
) -
Update/Insert
"typescript.tsdk": "./node_modules/typescript/lib"
Now only the project you installed this TypeScript version in will use that TypeScript version, the global installation will be ignored by VS Code in this project.
-
Having added the
typescript.tsdk
entry it’s then also necessary to use the VS Code UI to select the new version:
See also: