How to upgrade typescript to any specific version or latest version from Command Prompt

Updated on: May 27, 2021

Typescript helps you to write Object Oriented Programming, it provides classes and Interfaces. Angular uses Typescript language where we use Typescript to write Angular Components, Angular Service and Angular Classes. If you want to install and use Typescript on your machine, then you can install it using NPM command shown below and if you already have Typescript installed on your machine and you want to upgrade it to latest version, then following Steps will help you to upgrade it to Typescript latest version: 

Following is the command if you want to install and upgrade Typescript version to the latest Typescript version. Open the Node.js Command Prompt and execute the below command:

npm install -g typescript

Following is the command if you want to upgrade / downgrade Typescript to any specific version (e.g. 3.9, 3.8, 3.7, 3.6, 3.5, 3.0 etc.), execute the below command using Node.js command prompt:

npm install -g typescript@3.3

In the above command, we have set the Typescript version to 3.3, after setting to Version 3.3, our typescript code stopped working because code was having features of Typescript version 3.4+, so again after upgrading to latest Typescript Version 3.9, our code started working again. You can upgrade it to latest using our "npm install -g typescript" command which will install the latest Typescript version.

Once you upgrade / downgrade Typescript version, you can confirm the current installed version by executing following command, the below command will provide you which Typescript Version your machine is currently using for executing typescript (.ts) files:

tsc -v

You can see, my machine was using 3.9.5 Typesript Version, so it displayed "Version 3.9.5" when I executed "tsc -v" command.