Install TypeScript

Welcome to the tutorial on the Installation TypeScritp.

We have three ways to install TypeScript:

  • Install TypeScript as an NPM package on your local machine or project.
  • Install TypeScript NuGet Package directly in your .NET or .NET Core project.
  • Install TypeScript as a Plug-in in your IDE which is your Integrated Development Environment.

 

Install TypeScript using NPM

NPM (i.e. Node.js package manager) is used to install the TypeScript package on your local machine or your project. but, ensure you have Node.js installed on your local machine. However, in the case, you are making use of JavaScript frameworks for your application, then it is very much recommended to install Node.js.

Now, to install or update the latest version of TypeScript, open the command prompt/terminal and type the command below:

npm install -g typescript

The command above will install TypeScript globally for you to use in any project. You can check the installed version of your TypeScript by using the command below.

tsc -v 

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

npm install typescript --save-dev

 

Install TypeScript as NuGet Package

Using the .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, that will automatically compile all .ts files to .js files like tsconfig.json configuration when you build your project.

Now, 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. Then it will list all the packages related to TypeScript. Select Microsoft.TypeScript.MSBuild and then click on the Install button, it will install TypeScript in your local ASP.NET project.

 

TypeScript Visual Studio Extension

in this case, if your project type doesn’t support the NuGet packages, then you can use TypeScript Visual Studio Extension. So, you can find and install the extension in Visual Studio from Tools > Extensions and Updates menu.

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

 

Install TypeScript Plug-in in your IDE

One can as well install an IDE specific TypeScript package or plugin for his IDE.

Below are examples of plugins for popular code editors are: 

  • Atom-TypeScript: It is a TypeScript language service for Atom developed by TypeStrong.
  • TypeScript IDE for Eclipse: This is an Eclipse plugin developed by Angelo Zerr.
  • TypeScript Plug-in for Eclipse: This is an Eclipse plugin developed by Palantir.
  • The WebStorm includes TypeScript support out of the box.

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

 

TypeScript Playground

TypeScript provides an online playground on https://www.typescriptlang.org/play, for you to write and test your code on the fly without the need to download or install anything. Thus, it is a place for beginners to learn TypeScript and try different TypeScript features. also, with the link provided by the playground, you have the option to share your code.