It's pretty simple to install and get started with TypeScript. It is necessary to have Node.js and Node Package Manager (NPM) installed on your machine.
If you don't have them yet, go to https://nodejs.org/en/download/ and follow the step-by-step installation instructions for your platform.
Let's install TypeScript, as follows:
- Open your Terminal and type the following command to install the TypeScript compiler:
npm install -g typescript
Note that the -g flag means to install the compiler on your machine globally.
- Let's check the available TypeScript commands. Type the following command in the Terminal:
tsc --help
The preceding command will provide a lot of information about the TypeScript compiler; we will see a simple example of how we can transpile a TypeScript file to a JavaScript file.
Examples:
tsc hello.ts
tsc --outFile file...