Install TypeScript

There are three ways to install TypeScript:

  1. Install TypeScript as an NPM package on your local machine or in your project.
  2. Install TypeScript NuGet Package in your .NET or .NET Core project.
  3. Install TypeScript as a Plug-in in your IDE (Integrated Development Environment).

Install TypeScript using NPM

NPM (Node.js package manager) is used to install the TypeScript package on your local machine or a project. Make sure you have Node.js install on your local machine. If you are using JavaScript frameworks for your application, then it is highly recommended to install Node.js.

To install or update the latest version of TypeScript, open command prompt/terminal and type the following command:

npm install -g typescript

The above command will install TypeScript globally so that you can use it in any project. Check the installed version of TypeScript using the following command:

tsc -v

Execute the following command to install the TypeScript to your local project as dev dependency.

npm install typescript --save-dev

Install TypeScript as NuGet Package

For .NET or .NET Core projects, TypeScript can be installed as a NuGet package in your project. The NuGet package Microsoft.TypeScript.MSBuild is an MSBuild task for TypeScript, which will automatically compile all .ts files to .js files as per tsconfig.json configuration when you build your project.

To install the TypeScript NuGet package, open NuGet Package Manager by right-clicking on a project node, click Manage NuGet Packages.., and search for typescript in the Browse tab. It will list all the packages related to TypeScript. Select Microsoft.TypeScript.MSBuild and click on the Install button. This will install TypeScript in your local ASP.NET project.

TypeScript Visual Studio Extension

If your project type does not support the NuGet packages, then you can use TypeScript Visual Studio Extension. You can find and install the extension in Visual Studio from Tools > Extensions and Updates menu.

Visual Studio Code comes with built-in support for TypeScript.

Install TypeScript Plug-in in your IDE

You can install an IDE specific TypeScript package or plugin for your IDE.

A few examples of plugins for popular code editors are:

  1. Atom-TypeScript: a TypeScript language service for Atom developed by TypeStrong.
  2. TypeScript IDE for Eclipse: an Eclipse plugin developed by Angelo Zerr.
  3. TypeScript Plug-in for Eclipse: an Eclipse plugin developed by Palantir.
  4. WebStorm includes TypeScript support out of the box.

Visit TypeScript Github Repository for the full list of IDEs that support TypeScript development.

TypeScript Playground

TypeScript provides an online playground https://www.typescriptlang.org/play to write and test your code on the fly without the need to download or install anything.

This is a great place for beginners to learn TypeScript and try different TypeScript features. You also have the option to share your code via a shareable link provided by the playground.