TypeScript installation can be done in two ways:
To install TypeScript using node.js package manager, you need to make sure that the node.js has installed on your machine. In case, if node.js not installed on your machine, install it by following node.js installation article.
After completion of node.js installation on your machine, open node.js command prompt and execute
npm install -g typescript command to install TypeScript globally (
-g) on your computer like as shown below.
After successfully installation of TypeScript, it will show the typescript version info, etc. as shown in the above image.
If you would like to know the version information of TypeScript or would like to check the installation is done properly or not then execute
tsc -v command in node.js command prompt like as shown below.
Now, both node.js and typescript installed on your machine so you can start writing the code using the code editor of your choice. In the next chapters, we will learn more about it.
To write TypeScript code, you can use IDE of your choice such as Eclipse, Visual Studio, Visual Studio Code, Notepad++, WebStorm, NetBeans, etc. but you need to install TypeScript plug-in or package in your IDE to enable TypeScript development environment.
Following are the typescript plugins for few of popular code editors.
The Visual Studio comes with TypeScript when installing Microsoft Web Tools. You can also download TypeScript for Visual Studio 2019 and 2017 from here. For Visual Studio 2015, the TypeScript can be downloaded from here.
In case, if you are using Visual Studio 2013 you can download TypeScript from here.
Visual Studio Code is an open-source light-weight cross-platform (Windows, MacOS, and Linux) editor and it comes with built-in TypeScript support. You can download the Visual Studio Code from here.
TypeScript has provided an online code editor (https://www.typescriptlang.org/play) to write and compile TypeScript code online without installing any component on your machine.