Before we can start using TypeScript, it is necessary to have the required tools installed on our computer. So let’s see how we can install, update, and uninstall TypeScript.
Prerequisites
Node.js is a JavaScript runtime environment that allows us to run JavaScript on the server side. NPM (Node Package Manager) is the package manager that comes with Node.js.
We will need both to install TypeScript and run our programs.
- Install Node.js: Visit the official Node.js website and download the appropriate installer for your operating system. Follow the installation instructions.
- Verify the installation of Node.js and npm: Open a terminal and run the following commands. You should see the versions of Node.js and NPM installed.
node -v
npm -v
If you need more information about Node.js or NPM, here are my courses 👇
How to install TypeScript
With Node.js and NPM installed, you are ready to install TypeScript. The process is straightforward and can be done with a single command.
- Open your operating system’s terminal
- Run the following command to install TypeScript globally on your system:
npm install -g typescript
The -g
modifier ensures that TypeScript is installed globally (which means it will be available in any project on your machine). It’s that easy! :::
How to update TypeScript
To update TypeScript, open the terminal and run the following command:
npm update -g typescript
This command will update TypeScript to the latest available version.
How to uninstall TypeScript
If at any point you need to uninstall TypeScript, you can easily do so using NPM. Simply open the terminal and run the following command:
npm uninstall -g typescript
This will completely remove TypeScript from your system.
How to verify the installation of TypeScript
After installing TypeScript, it is advisable to verify that the installation was successful.
For that, open the terminal and run the following command
tsc -v
You should see the installed version of TypeScript. If the tsc
command (TypeScript Compiler) runs successfully and displays a version, it means that TypeScript is correctly installed on your system 👍.
Text Editor or IDE
To develop in TypeScript, you will need a text editor or an IDE that supports TypeScript. Visual Studio Code (VS Code) is one of the best options available and has integration with TypeScript.
If you want to learn more about “What it is and how to install Visual Studio Code”
check out the Introduction to Programming Course read more
It would also be advisable to install the TypeScript extension.
- In VS Code, go to the Extensions section (square icon in the sidebar)
- Search for ”TypeScript”
- Install the official Microsoft extension
If you’ve made it this far, congratulations! You now have everything you need installed on your computer and are ready to start programming in TypeScript. 🎉🥳