How to Change the Version of TypeScript Compiler in VSCode

mail
Cyrus Kao
Last modified

By default, VSCode uses its own TSC (TypeScript Compiler), which is usually not the latest version of TypeScript. To use the latest features, we'll need to install TypeScript in our package's dependencies and select the version from node_modules in VSCode (.vscode/settings.json).

Install TSC

Install the latest typescript as dev dependencies from NPM:

npm i -D typescript
Bash

Specific Version

To install a specific version of TypeScript:

npm i -D typescript@4.6.0-beta
Bash

Select in VSCode

Press Ctrl-Shift-P in VSCode to open command palette, search for Select Typescript Version...:

Command palette
Command palette in VSCode

You'll need to gain focus on a .ts or .tsx file before opening command palette, otherwise the options with TypeScript prefix won't show.

Select the Workspace Version (node_modules/typescript/lib):

Selecting TypeScript versions
Selecting TypeScript versions

Then a settings.json file will be created in .vscode folder, specifying the path of TSC binary:

settings.json
settings.json of VSCode

Comments

0500