Lesson 1 / 26
Why TypeScript?
A superset of JavaScript that adds static types.
What TypeScript adds
TypeScript is JavaScript plus static types. Every valid JS file is already valid TS — you opt into type checking gradually, and errors surface while you type, not in production.
A spellchecker for code
Plain JS runs your sentence even with a typo and fails later. TypeScript is a spellchecker — it underlines the mistake before you hit "send".
Caught before running
In plain JS this typo runs and silently returns undefined. TS refuses to compile it.
function greet(name: string) {
return `Hello, ${nmae}!`; // typo: 'nmae'
}
// Error: Cannot find name 'nmae'. Did you mean 'name'?