Welcome to the tutorial on the Installation TypeScritp.
We have three ways to install TypeScript:
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
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.
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.
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:
You can Visit TypeScript Github Repository for the full list of IDEs that support TypeScript development.
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.