Language: EN

como-instalar-typescript

How to install TypeScript

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 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.

  1. Install Node.js: Visit the official Node.js website and download the installer appropriate for your operating system. Follow the installation instructions.
  2. Verify the installation of Node.js and npm: Open a terminal and run the following commands. You should see the installed versions of Node.js and NPM.
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.

  1. Open the terminal of your operating system
  2. 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. Just open the terminal and run the following command:

npm uninstall -g typescript

This will completely remove TypeScript from your system.

How to Verify TypeScript Installation

After installing TypeScript, it is advisable to verify that the installation was successful.

To do this, open the terminal and run the following command

tsc -v

You should see the installed version of TypeScript. If the tsc (TypeScript Compiler) command runs successfully and shows a version, it means 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 available options, and it has integration with TypeScript.

It would also be advisable to install the TypeScript extension.

  1. In VS Code, go to the Extensions section (square icon in the sidebar)
  2. Search for ”TypeScript
  3. Install the official Microsoft extension

vscode-extension-typescript

If you’ve made it this far, congratulations! You now have everything you need installed on your computer and you’re ready to start programming in TypeScript. 🎉🥳