TypeScript Setup

Lesson 2: Installing TypeScript and Setting Up the Environment

Prepare your computer for TypeScript development by installing Node.js, the TypeScript compiler, and creating your first simple project.

What You Need

To use TypeScript, you need Node.js and npm. npm allows you to install the TypeScript compiler. A code editor such as Visual Studio Code or Visual Studio 2026 also makes development easier.

Step 1: Install Node.js

Download and install Node.js. After installation, verify that it works:

node -v
npm -v

Step 2: Install TypeScript

Install TypeScript globally so the compiler can be used anywhere:

npm install -g typescript

Then verify the installation:

tsc -v

Step 3: Create a Project Folder

mkdir my_ts_project
cd my_ts_project

Step 4: Create Your First File

let message: string = "Hello, TypeScript!";
console.log(message);

Step 5: Compile the File

tsc app.ts

This generates app.js, which you can run with Node.js:

node app.js

Using tsconfig.json

For bigger projects, create a configuration file:

tsc --init
{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "strict": true,
    "outDir": "dist"
  }
}
Tip: Compile the whole project with tsc once your tsconfig.json file is ready.

Summary

You have now installed the TypeScript compiler, created a project folder, and compiled your first file. This environment is enough to continue the tutorial series.