TypeScript Environment Setup

To set up TypeScript on your machine, you will need to have Node.js and npm (Node Package Manager) installed. Here are the steps to set up TypeScript:

Note: make sure node & npm is installed in your machine, before performing below steps.

1. Open the terminal/command prompt.

2. Install TypeScript globally by running the following command:

3. Verify the TypeScript installation by running the following command:

4. Create a new directory for your TypeScript project and navigate to it.

5. Initialize npm in the project directory by running the following command:

6. Create a new TypeScript file, for example, “index.ts”.

7. Compile the TypeScript file to JavaScript by running the following command:

8. The above command will generate a new JavaScript file named “index.js”.

9. run below command to see output:

Great!

You now have TypeScript set up on your machine.

Understanding Typescript Compiler

Whenever you write code in typescript with .ts extension. for example:  index.ts  . the typescript compiler will compile and translate the code to javascript which is index.js. this process is called transpiler.

Below is the transpiler flow.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top