Everyday Types, Deep
The types you already use — properly understood
Section titled “The types you already use — properly understood”You reach for these every day: string literals, unions, object shapes, tuples, functions. This module slows down on the parts that trip people up — widening, as const, the difference between a union and an intersection, and the control-flow narrowing that makes unions actually usable.
Everything here rests on the foundations model: a type is a set of values. Keep that lens and each feature is just a way of describing or shrinking a set.
What this module covers
Section titled “What this module covers”| Lesson | What you’ll learn |
|---|---|
| Literals & widening | Literal types, when they widen, and as const |
| Unions & intersections | A | B (wider) vs A & B (narrower), and how to work with each |
| Objects, arrays & tuples | Optional/readonly properties, index signatures, tuples |
| Functions | Overloads, this typing, rest params, the void nuance |
| Narrowing | Turning a union into a specific type with control flow |
The through-line: describe, then narrow
Section titled “The through-line: describe, then narrow”flowchart LR describe["Describe the shape (literals, unions, objects)"] --> hold["Hold a wide type (a union of possibilities)"] hold --> narrow["Narrow with control flow (typeof, in, discriminants)"] narrow --> use["Use the specific type safely"]
You describe data with unions and object types, which leaves you holding a wide type (several possibilities). Then you narrow — with typeof, in, a discriminant field — down to the one specific case, and TypeScript lets you use it safely. Master that loop and you’ve mastered day-to-day TypeScript.