Lesson 1: Why TypeScript? The Case for Types
JavaScript is dynamically typed, which is great for quick scripts but painful at scale. TypeScript adds a static type layer on top of JavaScript that catches bugs before you run your code.
What you get
- Autocomplete that actually knows your data shapes
- Compile-time errors instead of runtime surprises
- Self-documenting function signatures
- Safe refactoring across large codebases
function greet(name: string) {
return `Hello, ${name.toUpperCase()}`;
}
greet(42); // โ Error: number is not assignable to string
TypeScript compiles down to plain JavaScript, so it runs anywhere JS runs โ the browser, Node, Deno, or a static site like this one.