Typescript – What TypeScript version is Visual Studio Code using? How to update it

typescriptvisual-studio-code

How can I tell what version of TypeScript is being used in Visual Studio Code? In particular, I had been using TypeScript 1.8.10 and VSCode 1.4.0. I first updated VSCode to the latest version, which was 1.5.3. But checking from the command line, I saw that my TypeScript version was still 1.8.10. So I updated TypeScript from the command line, and it is now 2.0.3 .

Is there a way to tell for sure whether Visual Studio Code is using version 2.0.3?

Is there a method for updating Visual Studio Code that will automatically update TypeScript to the latest released version, or does the TypeScript update have to be done independently?

Best Answer

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:

VS Code status bar TypeScript version


Changing the global TypeScript version

  1. Install the desired TypeScript version globally, for example npm install -g typescript@2.0.5
  2. Open VS Code User Settings (F1 > Open User Settings)
  3. 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

  1. Open the project in VS Code
  2. Install the desired TypeScript version locally, for example npm install --save-dev typescript@2.0.5

    The --save-dev will update your project's package.json, adding the TypeScript version you installed as a devDependency.

  3. Open VS Code Workspace Settings (F1 > Open Workspace Settings)

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

  5. Having added the typescript.tsdk entry it's then also necessary to use the VS Code UI to select the new version:

    • Click on the version displayed in the VS Code footer:

      vs code footer

    • Select it in the UI:

      select ts version in UI


See also: