How To Install (Upgrade or Downgrade) a TypeScript Version?

To install TypeScript on your machine, use the following command if you use npm.

npm i typescript

This will automatically install the latest version of TypeScript.

If you rather prefer using yarn, use the following command.

yarn add typescript

Similar to using npm, this will also install the latest version of TypeScript by default.

How to Install the Latest TypeScript Version

Every now and then it is common to see newer package versions, and TypeScript is not the exception. Hence, the version installed locally might not match the current latest version of the package.

To install the latest TypeScript version, add @latest when using the same command to install TypeScript.

Hence, this will look like the following command if you use npm,

npm i typescript@latest

or like the following example if you use yarn.

yarn add typescript@latest

How to Upgrade or Downgrade to a Specific TypeScript Version

Sometimes, projects run on a specific TypeScript version. Whether you are upgrading or downgrading to a specific TypeScript version, add @<version> . Hence, if the desired version to install is 4.4.3, it would be @4.4.3.

Check the list of TypeScript versions if you don’t know all the versions available.

Therefore, if your current TypeScript version is 4.3.2, and you want to upgrade to Typescript version 4.4.3, use the following command if you use npm,

npm i [email protected]

or the following if you use yarn.

yarn add [email protected]

Remember, the same command used to upgrade TypeScritpt, can also be used to downgrade it.

Was this article helpful?

Did this article solve your problem?

Hopefully, this article helped you figure out not only how to install TypeScript, but also upgrade or downgrade to a specific TypeScript version.

Follow us on Twitter of Become A Better Programmer or to my personal Twitter account, and stay tune to more articles in the Blog.