0Pricing
TypeScript Academy · Lesson

satisfies vs Type Annotation

Keep literal inference while still validating shape.

The Annotation Pattern

The classic pattern const config: Type = {...} validates the object but the variable type becomes Type, widening any literals inside.

type Config = { mode: string; level: number };
const config: Config = { mode: "dark", level: 5 };
// config.mode has type string
console.log(config.mode);

What Widening Looks Like

With the annotation, config.mode is string. You cannot assign it to a variable expecting the literal "dark".

type Config = { mode: string };
const config: Config = { mode: "dark" };
// const m: "dark" = config.mode; // Error: string not assignable to "dark"
console.log(config.mode);

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