Lesson 4.2

Typing external data at the boundary

Data from the network is unknown until you prove otherwise. A runtime schema validates it once and gives you a static type for free.

Duration
7m
Level
Intermediate
Students
11k students

Overview

Data from the network is unknown until you prove otherwise. A runtime schema validates it once and gives you a static type for free.

In this lesson you will:

  • Parse unknown input instead of casting it
  • Derive a static type from a runtime schema
  • Fail loudly at the boundary rather than deep inside

Resources

TypeScript handbook

The official reference for the tools used in this lesson.

Zod documentation

Schema definition, parsing, and type inference.