Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Why TypeScript? · Lesson 1 of 12

What Is TypeScript?

A free lesson from Swipe Coding · TypeScript, level 1 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
TypeScript's whole superpower is catching bugs before you even hit run — let's see it in action. 🕵️

JavaScript never checks whether the values flowing through your code are the kind you expect until the moment that code actually runs. TypeScript is a superset of JavaScript, created by Microsoft, that layers a type system on top of it — so a whole category of mistakes gets caught the moment you save the file, before you ever hit run.

function greet(name: string) {
  return "Hello, " + name.toUpperCase();
}

greet(42); // Error: Argument of type 'number' is not assignable to parameter of type 'string'.
In plain JavaScript, greet(42) would run and only crash later at name.toUpperCase() — numbers don't have that method. TypeScript catches the mistake immediately, right at the call site, before the code ever executes.

That's the core idea: TypeScript checks types at compile time — while you're writing the code — instead of at runtime, while it's running on someone's machine. The earlier a bug is caught, the cheaper and less embarrassing it is to fix.

🤖
Autocomplete that actually knows what it's talking about — that's the payoff of typed code. 💡

Types also make your editor smarter. Once TypeScript knows a variable's exact shape, it can offer accurate autocomplete, flag typos in property names, and show you exactly what a function expects — all without running a single line of code.

const user = { name: "Ravi", age: 29 };

user.ag; // Editor flags this immediately: Property 'ag' does not exist on type '{ name: string; age: number; }'. Did you mean 'age'?
Because TypeScript knows user's exact shape, it catches the typo ag right away instead of silently returning undefined the way plain JavaScript would.

Here's the part that surprises a lot of beginners: browsers and Node.js can't run .ts files directly. TypeScript is compiled — translated — down into plain JavaScript before it ever runs. The type annotations only exist to help you while you write; by the time the code actually runs, they've been stripped away entirely.

Fill in the blank

TypeScript is a ____ of JavaScript that adds a type system on top of it.

Quick check

Why does TypeScript catch more bugs than plain JavaScript before the code ever runs?

True or false

Browsers can execute .ts files directly, without any compilation step.

Keep your streak going in Swipe Coding

Swipe through every level of TypeScript on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.

Get the Swipe apps →