JavaScript Plus Types, Checked Before You Run
What is TypeScript?
TypeScript is JavaScript with a static type system bolted on. You add type annotations; the compiler checks for mistakes before the code ever runs.
What you'll learn
- Understand what TS is and isn't
- See how types prevent bugs
- Recognize TS code at a glance
TypeScript is JavaScript with a static type system. You annotate values with their expected types; the compiler checks that every use matches. Bugs caught before the code ever runs.
Side By Side
// JavaScript
function add(a, b) {
return a + b;
}
add("1", 2); // "12" — silent string concat, runs anyway // TypeScript
function add(a: number, b: number): number {
return a + b;
}
add("1", 2);
// ~~~ Argument of type 'string' is not assignable to parameter of type 'number'. Same logic. TypeScript catches the bad call at compile time. You ship JavaScript; TypeScript just made sure you didn’t ship a bug.
What TS Is
- A superset of JavaScript — every valid JS is valid TS
- A type system layered on top — annotations and inference
- A compiler that strips types, outputting plain JS
- A language server that powers autocomplete and refactors in every modern editor
What TS Is NOT
- A new runtime — your code runs as plain JS in a browser or Node
- Magically faster — types are erased at build time
- A guarantee against ALL bugs — only the type-related ones
- Only for big projects — works great in 30-line scripts too
What You’ll Get
Once you’re comfortable, TypeScript gives you:
- Autocomplete that actually knows your data shapes
- Refactor safely — renames flow through types
- Catch bugs without running — compile-time checks
- Document via types — types ARE the docs, always up to date
- Confidence at scale — refactor 100k LOC and trust the compiler
The Sequence Ahead
This course builds up:
- Basic types (this chapter)
- The essentials — interfaces, unions, narrowing
- Function types in depth
- Generics
- The advanced toolbox — keyof, mapped, conditional types
- OOP with classes
- Real-world — tsconfig, Node, React, migrating from JS
Up Next
A 60-second setup.
Setup →