0Pricing
TypeScript Academy · Lesson

Why satisfies Exists

The gap between annotation and inference that satisfies fills.

The Two Goals in Tension

When you declare a config, you usually want two things: validation against a known shape, and precise inference of the literal values. These goals often conflict.

type Color = "red" | "green" | "blue";
// We want both: check the values AND remember exactly which ones.

Annotation Loses Literal Narrowing

Adding a type annotation validates the object but widens the values. The compiler forgets the exact literals you wrote.

type Config = { color: string; retries: number };
const cfg: Config = { color: "red", retries: 3 };
// cfg.color is string, not "red" anymore.
console.log(cfg.color.toUpperCase());

All lessons in this course

  1. Why satisfies Exists
  2. satisfies vs Type Annotation
  3. satisfies vs as Assertion
  4. Practical satisfies Patterns
← Back to TypeScript Academy