Skip to content

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.

LessonWhat you’ll learn
Literals & wideningLiteral types, when they widen, and as const
Unions & intersectionsA | B (wider) vs A & B (narrower), and how to work with each
Objects, arrays & tuplesOptional/readonly properties, index signatures, tuples
FunctionsOverloads, this typing, rest params, the void nuance
NarrowingTurning a union into a specific type with control flow
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"]
Everyday typing is describe then narrow

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.

What is the recurring rhythm of everyday TypeScript?
Which underlying model ties this whole module together?