M Logo
📁 TypeScript from Zero · Part 1 of 50

TypeScript from Zero: Setup and Your First Program

November 6, 2026

Welcome to TypeScript from Zero, a series for complete beginners: you do not need to know JavaScript or any other language. In this first episode we install the tools, write one line of code, run it, and see why TypeScript exists. Every code block below is the exact code and output from the video, ready to copy.

1. What TypeScript is

TypeScript is JavaScript plus types. A type says what kind of value something is, like a number or a piece of text. Because of that, a tool can find mistakes before the program runs.

2. Check the tools

Node.js runs our programs outside the browser. npm comes with it and installs packages. Check both versions (Node 26 or newer):

bash
node --version
npm --version
text
v26.13.0
11.20.0

3. Create the project

A folder, an empty file whose name ends in .ts (TypeScript), and VS Code:

bash
mkdir hello-ts
cd hello-ts
touch hello.ts
code .

4. The first program

console.log prints text to the terminal. Put this in hello.ts:

ts
console.log("Hello, TypeScript!");

5. Run it

Recent versions of Node run TypeScript files directly. Node just removes the types and runs the rest:

bash
node hello.ts
text
Hello, TypeScript!

6. A typo crashes at run time

Change the line to consol.log(...) (no e) and run it again:

ts
consol.log("Hello, TypeScript!");
text
ReferenceError: consol is not defined
    at Object.<anonymous> (file:///home/mah/hello-ts/hello.ts:1:1)

Node checks nothing before it starts, so the program crashes while it runs.

7. Install TypeScript

npm init -y creates a package.json for the project, and npm install adds TypeScript to it:

bash
npm init -y
npm install --save-dev typescript

8. tsc finds the mistake first

tsc is the TypeScript compiler. --noEmit means: only check, write no files.

bash
npx tsc --noEmit hello.ts
text
hello.ts:1:1 - error TS2552: Cannot find name 'consol'. Did you mean 'console'?

The code TS2552 names this kind of error. Node runs code, tsc checks code. We will use both in this series.

9. Fix and check again

Put console.log back. When tsc prints nothing there are no errors:

bash
npx tsc --noEmit hello.ts
node hello.ts
text
Hello, TypeScript!

Recap

  • TypeScript is JavaScript plus types.
  • node file.ts runs a file, npx tsc --noEmit file.ts checks it.
  • Every error has a code, like TS2552.

Next episode: Variables with let and const.

© 2026 All Rights Reserved By Mahmudul Alam