<>
24
TypeScript and the runtime

TypeScript and the runtime

Types are claims about runtime values. Seven lessons on the boundaries — fetch, JSON, localStorage — and how to verify what crosses them.

~ 110 min·7 lessons·updated apr 2026

What you'll learn


Lessons

Read in order. Each lesson stands on its own, but the order is deliberate.

7 lessons · ~104 min total

  1. 01
    The trust boundary
    Where types are honest, and where they are a hopeful claim about runtime values.
    13 min
  2. 02
    Type guards and predicates
    Custom checks that teach the compiler what your code already knows.
    15 min
  3. 03
    Assertion functions
    Failing loud at the boundary instead of returning a boolean.
    13 min
  4. 04
    Schema validation with Zod
    One schema as the source of truth for both runtime checks and TypeScript types.
    18 min
  5. 05
    Schema validation alternatives
    Valibot, ArkType, and when Zod is the wrong default.
    13 min
  6. 06
    Typing fetch responses
    Why `as User` is a lie, and how to validate the data you actually got.
    16 min
  7. 07
    Local storage and untrusted persistence
    Yesterday's data is a stranger. Versioning and migrations on read.
    16 min

Prerequisites

  • · typescript-essentials
  • · typescript-design-patterns
  • · Comfortable with promises and fetch

After this, try

  • Typed APIs
  • Form validation patterns
  • Observability with TS