Foundations & Mental Model
The idea in one sentence
Section titled “The idea in one sentence”TypeScript is JavaScript plus a static type system that runs at compile time and disappears at runtime. It doesn’t change what your code does — it changes what the compiler will let you write, catching whole classes of bugs before the code ever runs.
Everything advanced in this course — generics, conditional types, mapped types — is just this one system taken to its logical conclusion. Get the mental model right and the rest follows.
What this module covers
Section titled “What this module covers”| Lesson | What you’ll learn |
|---|---|
| Why TypeScript | What types buy you, and the compile-time / runtime split |
| The type-system mindset | Types as sets of values — the single most useful mental model |
| Structural typing | Why TypeScript cares about shape, not names |
| Type inference | How the compiler figures out types you didn’t write |
The lens for the whole course
Section titled “The lens for the whole course”Two ideas, held together, explain almost every TypeScript behavior you’ll ever hit:
flowchart TB sets["Types are SETS of values (number = all numbers)"] --> assign["Assignability = subset relationship"] struct["Typing is STRUCTURAL (shape, not name)"] --> compat["Compatibility = does the shape fit?"] assign --> ts["Every TS behavior"] compat --> ts
When an assignment is allowed, it’s because one type’s set of values fits inside another’s. When two objects are interchangeable, it’s because their shapes match. Hold those two ideas and TypeScript stops surprising you.