Ch. 2 · TypeScript

TypeScript Satisfies Without Losing Inference

TypeScript Satisfies Without Losing Inference. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readbeginnerupdated Oct 3, 2026

Satisfies checks compatibility while preserving the expression’s useful inferred type. It suits configuration whose keys and values should remain precise.

Before you start

You should be comfortable with JavaScript values, functions and objects. Use a TypeScript project with strict checking enabled when trying the examples. Separate what the compiler proves from what must still be checked when values arrive at runtime.

The practical goal is to reason through this situation: A route map can satisfy a Record contract while retaining its known route keys. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Describe permitted values

Define a common route contract, including required fields. The contract should express compatibility without declaring every known configuration key.

Step 2: Check the expression

Apply satisfies where the object is created. Misspelled fields and incompatible values can be detected while the known route names remain available.

Step 3: Use retained precision

Read a specific key from the inferred object. Avoid adding a broad annotation afterward that discards the precision you wanted to retain.

Worked scenario

A route map can satisfy a Record contract while retaining its known route keys.

type Route = { path: string; public: boolean };
const routes = {
  home: { path: '/', public: true },
  account: { path: '/account', public: false },
} satisfies Record<string, Route>;
type RouteName = keyof typeof routes; // 'home' | 'account'
TypeScript

Changing public to a string fails compatibility checking. The object still has its actual home and account keys; satisfies does not turn it into an arbitrary-key dictionary.

Common mistake

Satisfies does not parse or validate incoming runtime data.

Verify the behavior

Introduce an invalid property type, then try an unknown route key. Also pass external JSON through runtime validation rather than assuming satisfies runs in the browser.

Interview exercise

Contrast annotation and satisfies.

Answer and reasoning

An annotation can widen the variable to the contract; satisfies checks the expression without replacing its inferred shape.

Continue learning

Compare the scenario with the TypeScript interview questions and test your understanding with the TypeScript MCQs. For terminology and implementation details, consult the reference material.

More in TypeScript

read ✓TypeScript · hard

TypeScript Abstract Classes and Contracts

Share behavior with abstract classes, enforce required members, and decide when an interface or composition is the better contract.

~2 min readread →
read ✓TypeScript · mid

TypeScript Enums vs Union Types

Compare enums with unions of string literals: runtime cost, serialization, exhaustiveness and which one fits application code.

~3 min readread →
esc