The `satisfies` Operator (Why It’s a Big Deal)
How `satisfies` helps validate shapes without losing literal types, and why it often beats `as const` and type annotations.
On this page
30‑second interview answer
satisfies lets you check that a value conforms to a type without changing the value’s inferred type. It’s perfect for config objects: you get shape validation plus you keep literal types for autocomplete and safety.
The problem
If you annotate an object, you widen its types to the annotation:
type Route = { path: string; auth: boolean };
const routes: Record<string, Route> = {
login: { path: '/login', auth: false },
dashboard: { path: '/dashboard', auth: true },
};
// Problem 1: routes.login.path is widened to string (not '/login').
// Problem 2: routes.settings does not error at compile-time because the index signature allows any string key!The satisfies solution
satisfies checks that a value conforms to a type without widening its inferred type:
type Route = { path: string; auth: boolean };
const routes = {
login: { path: '/login', auth: false },
dashboard: { path: '/dashboard', auth: true },
} satisfies Record<string, Route>;
// 1. Exact keys are preserved: routes.settings is a compile-time error!
// 2. Exact literals are preserved: routes.login.path is literal '/login', not just string.
// 3. Invalid shapes are caught immediately:
// const bad = { test: { path: 123 } } satisfies Record<string, Route>; // Error!Another classic interview example is union validation without losing method access:
type RGB = [red: number, green: number, blue: number];
type Color = string | RGB;
const palette = {
primary: '#3b82f6',
accent: [16, 185, 129],
} satisfies Record<string, Color>;
// TypeScript validates that both are valid Colors, but still knows:
palette.primary.toUpperCase(); // Valid! TS knows primary is a string.
palette.accent.map((c) => c * 2); // Valid! TS knows accent is an array.Why it beats as const sometimes
as const makes everything readonly and literal:
const x = { mode: 'prod' } as const;satisfies keeps inference more flexible while still validating.
Common interview traps
- Confusing
satisfieswith type assertions. - Using
asto silence errors (dangerous).
Mini Q&A
Q1: Does satisfies change runtime value?
- No.
Q2: Why use satisfies instead of annotation?
- Keeps literal inference.
Q3: Is it like as?
- No.
ascan lie; satisfies validates.
Summary checklist
- I can explain the benefit: validation + literal types.
- I can use it for configs.
- I avoid using
asto silence errors.
Looking for structured, offline interview prep?
Free online lessons • Portable Amazon Kindle / Paperback
Frontend Interview Guide (2025 Edition)
By Rajesh Dhiman
Comprehensive preparation covering React internals, Web Performance, CSS architecture, and system design questions.
JavaScript Interview Guide
By Rajesh Dhiman
Deep dive into the Event Loop, microtask draining, closures, prototypal inheritance, and asynchronous execution patterns.
Note: All lessons on Frontend Interview remain completely free to read online. As an Amazon Associate, we may earn from qualifying purchases.
Written by Rajesh Dhiman
Authored by Rajesh Dhiman and engineered at Eunix Tech. Focused on deep-dive frontend engineering, JavaScript runtime internals, React architecture, and web performance.