Free Handbook · Runs in your browser

TypeScript Handbook

Learn TypeScript by running it. Seventeen modules from your first annotation to a job: every example is editable and runs right here, generics and narrowing are traced line by line, and the real compiler errors you will hit are explained with the fix. The type system, interfaces and classes, advanced and utility types, modules and declaration files, tsconfig, TypeScript with React, Node, Postgres and Docker, data structures and algorithms, sixty interview questions, a certification exam, and a resume check at the end.

0 / 105 lessons🔥 0 day streak
ShareXLinkedIn

How this handbook works

Every lesson has code you can edit and run right here — the interpreter runs in your browser, nothing to install, a trace of what the interpreter did line by line where that matters, and the real error you will hit next, with why the interpreter said it and the fix. Lessons tick themselves as you go. Finish the handbook, sit the exam, get the certificate, then take your resume through the ATS checker and on to jobs.

17modules
105lessons
79runnable examples
51real errors explained

Module 00 · what you'll be able to do

  • Explain what TypeScript adds to JavaScript and why teams pay the setup cost for it
  • Run TypeScript three ways, including right here with no install
  • Read a minimal tsconfig.json and know which five options matter
  • Tell inferred types from annotated ones, and know when to write the annotation anyway
01

Why TypeScript

TypeScript is JavaScript with a type checker bolted on at compile time. Every valid JavaScript program is (almost) valid TypeScript — the type checker just refuses to compile the ones it can prove are wrong before they run. Assign a string where a function expects a number, call a method that does not exist on an object, forget to handle the null case — TypeScript catches all three while you type, not when a user does.

It compiles down to plain JavaScript — the types are erased, not shipped. There is no "TypeScript runtime"; there is a compiler (tsc) that reads your .ts files, checks the types, strips them, and writes out .js. That is also why a type error is never something a user sees: it either stops the build, or your team ships it anyway and the type checker did its job for nothing. This handbook is about the first kind of team.

  • Catches bugs before runtime — a typo in a property name, a function called with the wrong argument order, forgetting a case in a switch.
  • Autocomplete that is actually correct — your editor knows the exact shape of every object, because the compiler does.
  • Safe refactoring — rename a field and the compiler lists every call site that breaks, instead of you finding them in production.
  • The de facto standard — React, Node, Angular, most serious open-source libraries ship TypeScript types; most job listings for "JavaScript" now mean this.
It is not a different language
Every lesson in the JavaScript handbook still applies — closures, this, the event loop, prototypes, all of it. This handbook does not repeat that; it teaches the layer TypeScript adds on top. If a run block here confuses you at the JavaScript level, that lesson is the one to read first.
02

Three ways to run TypeScript

You do not need to install anything for this handbook — every example below has a Run button. But you will use the other two on day one of any real TypeScript project.

  1. 1
    1. tsc — the compiler

    npm i -g typescript, then tsc app.ts reads app.ts, type-checks it, and writes app.js next to it. tsc --noEmit checks without writing anything — the command most CI pipelines run.

  2. 2
    2. ts-node — compile and run in one step

    npm i -D ts-node, then npx ts-node app.ts compiles in memory and runs it immediately. Convenient for scripts; production servers still compile ahead of time with tsc.

  3. 3
    3. Right here

    Every typescript block on these pages is an editor. Press Run, or /Ctrl + Enter. Your types are stripped and the result runs in your browser — nothing is sent to a server.

typescriptEdit it. ⌘/Ctrl + Enter runs.
You should see
Hello, TypeScript!
42
Your turn
Change answer to "42" — a string in quotes. Nothing turns red here (this editor does not type-check, only strips and runs — the next lesson explains why), but run it through tsc on your own machine later and watch it refuse to compile.
What this page can and cannot catch
The editor on this page strips your type annotations and runs the plain JavaScript that is left — same engine as the JavaScript handbook. It proves your code's runtime behaviour, but it does not run the type checker, so a type error here will not turn red the way it would in your editor or tsc. Every error card in this handbook (like the one at the end of Module 01) shows the real message tsc gives, copied from actually running it — that is where you learn what the checker catches.
03

tsconfig.json — the five settings that matter

tsconfig.json at your project root tells tsc (and your editor) how to check your code. tsc --init generates one with every option commented; almost all of it is defaults you will never touch. Five options decide how strict and modern your project is.

json
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}
OptionWhat it does
targetWhich JavaScript version tsc emits — ES2020 is a safe modern default; browsers/Node handle it natively.
moduleThe module system in the output — ESNext for modern bundlers/Node ESM, CommonJS for older Node require() projects.
strictTurns on the whole strict family at once (strictNullChecks, noImplicitAny, and six more). Always on for a new project — Module 11 explains each flag it bundles.
esModuleInteropLets import x from "cjs-package" work against old CommonJS packages without ceremony.
skipLibCheckSkips type-checking inside .d.ts files from node_modules — a dependency's own type bugs are not your problem, and this keeps builds fast.
"strict: false" is a trap, not a shortcut
Without strict, a variable with no annotation and no inferable type silently becomes any — TypeScript stops checking it entirely. A codebase that started without strict accumulates any the way an untested codebase accumulates bugs: invisibly, until the day it is not. Module 11 goes deep on this; for now, always start new projects with strict: true.
04

Your first typed program, traced

A function with typed parameters and a typed return value, called and printed. Every idea in it — annotations, inference, interfaces — gets its own lesson starting Module 01. First, run it. Then step through the trace to see what actually executes once the types are gone.

typescriptEdit it. ⌘/Ctrl + Enter runs.
You should see
Cost: 36
3 items at $12 = $36
Your turn
Call total("12", 3) instead — a string price. This still runs here (no type checker on this page), but paste it into the TypeScript Playground or your own editor and read the exact error it produces.
VisualizeWhat actually executes (types are already gone)Step 1 / 4
function total(price: number, quantity: number): number {
return price * quantity
}
const cost: number = total(12, 3)
console.log("Cost:", cost)
Line 1

The compiler already checked and erased : number on both parameters and the return type. At runtime this is a plain JavaScript function.

Variables now

nothing yet

All 4 steps as a table
StepLineWhat happenedVariables now
11The compiler already checked and erased : number on both parameters and the return type. At runtime this is a plain JavaScript function.
22Multiply the two arguments.
34Call total(12, 3), bind the result to cost. The : number annotation was a compile-time promise, already verified — nothing checks it again here.cost = 36
45Print the label and the value.
Type annotation
The : number part — you writing down what a value's type is.
Type inference
TypeScript figuring out a type without you writing it — const cost = total(12, 3) is inferred as number because total returns one.
Erasure
Types exist only while tsc is checking your code. The compiled .js has none of them — this is why you cannot check a type at runtime with typeof the way you check number vs string.
05

Inference vs annotation: when to write the type

TypeScript infers a type from the value you assign whenever it can — you do not have to annotate everything, and over-annotating is a beginner tell. The rule of thumb: let TypeScript infer local variables; annotate function boundaries.

typescriptEdit it. ⌘/Ctrl + Enter runs.
You should see
Ada 36 2 100

Let it infer

  • A const initialised right away — const x = 5
  • A variable whose value obviously reveals its type
  • Return values TypeScript can work out from the function body

Annotate it

  • Function parameters — TypeScript cannot infer what a caller will pass
  • A variable declared before it is assigned — let x: number
  • A public function's return type — locks the contract, catches an accidental change
Hover to check your mental model
In VS Code, hover any variable and it shows the inferred type — this is the fastest way to build intuition for what TypeScript figured out on its own versus what you told it.
06

How this handbook works

Seventeen modules, each its own page. The rail on the left lists them; the bar at the top and the pill at the bottom-left track how far you are. A lesson ticks itself when you reach its end or run its code, and the tick survives closing the tab — no account needed.

  • Run blocks are editors — your types, stripped and executed, so you see real runtime behaviour.
  • Error cards are real tsc compiler errors, copied from actually running the checker — because a run block on this page cannot show you a type error (Module 00, previous lesson explains why). Module 10 collects the fifteen most common.
  • Traces show what survives after the compiler erases your types — the mental model that makes generics, narrowing and inference click.
  • Interview questions appear where the topic is taught and are collected in Module 15, tiered junior / mid / senior.
  • The handbook ends with a certification exam (Module 16 → exam), then the ATS resume checker and the job board.
The tutor
The pill at the bottom-left opens a tutor that can see the code you last edited on this page. Ask it "why does tsc reject this" and it answers about your code. It is a language model — verify what it says against a real compiler.
07

Using AI to learn (without letting it learn for you)

An AI can write correctly-typed TypeScript in seconds. That is exactly why you should type the annotations yourself while learning: the goal is not the code, it is the model in your head of what the compiler can prove and what it cannot — the thing that lets you read someone else's generic type in an interview and explain what it does.

Do this

  • Paste a real tsc error and ask what it means — then fix it yourself
  • Ask "why does TypeScript infer this as string | undefined, not string"
  • Write the interface first, then ask for a review
  • Ask for an edge case your type does not cover

Not this

  • Ask for the answer to the "Your turn" task and paste it in
  • Copy a generic type you cannot explain parameter by parameter
  • Silence a type error with as any because the AI suggested it
  • Use it in an interview (they can tell)

Ready? Module 01 starts with the type system itself — primitives, arrays, tuples, and the three types every beginner reaches for too early: any, unknown and never.

Every lesson in the handbook

17 modules · 105 lessons · each one ticks itself when you reach the end or run its code.

00Getting Started0 / 7
01Basic Types0 / 7
02Type Annotations & Inference0 / 5
03Functions0 / 6
04Interfaces & Type Aliases0 / 7
05Classes & OOP0 / 6
06Generics0 / 6
07Unions, Intersections & Narrowing0 / 6
08Advanced & Utility Types0 / 6
09Modules & Declaration Files0 / 6
10Errors & Debugging0 / 7
11Configuration0 / 5
12TypeScript + Tools0 / 8
13Data Structures & Algorithms0 / 10
14Problem Solving0 / 5
15Interview Questions0 / 3
16Job Ready0 / 5

Frequently asked questions

Is this TypeScript handbook free?
Yes — every module, every runnable example and the certification exam are free, with no signup and no paywall. The exam asks you to sign in with Google so the certificate can carry your name.
Do I need to know JavaScript first?
Yes, at least the basics — TypeScript is JavaScript with a type system on top, and this handbook does not re-teach closures, the event loop or prototypes. The JavaScript handbook covers those; this one starts from there.
Do I need to install anything?
No. Every example runs inside your browser: press Run and a TypeScript engine is loaded once (your types are stripped and the result runs through the same interpreter the JavaScript handbook uses), then everything executes locally in a Web Worker. Nothing you type is sent to a server. Module 00 shows you how to install the real compiler for when you build actual projects.
Can this page show me real type errors?
The run blocks strip and execute your code, the same way a bundler does at runtime — they cannot show a compile-time type error. Every error card in this handbook is the real message tsc gives, copied from actually running the compiler, so you learn to read exactly what you will see in your own editor.
Is there a certificate?
Yes. Pass the 25-question exam with 70% or more and generate a SolutionGigs TypeScript certificate with your name, score, date and a certificate ID — download it, print it or add it to LinkedIn.

Finish the TypeScript handbook, then get hired

Sit the exam for your certificate, run your resume through the ATS checker, and see the jobs that ask for exactly this.

Check my resume
Found this course useful? Share it.
ShareXLinkedIn

Comments

0

Join the conversation. Sign in to leave a comment — we'd love to hear your thoughts.