Satisfies Operator
In this page:
Basic satisfies Usage
The satisfies operator checks that an expression conforms to a required type without changing the type TypeScript actually infers for that expression — you get validation and precise inference at the same time.
Example: Basic satisfies Usage
type Config = { port: number; host: string };
const config = { port: 8080, host: "localhost" } satisfies Config;
console.log(config.port);
Preserving Literal Information
Unlike a broad type annotation, satisfies preserves specific literal information from the original expression, so a value checked with satisfies keeps its narrow, literal type instead of being widened to the annotation's type.
Example: Preserving Literal Information
type Colors = Record<string, string>;
const palette = { red: "#ff0000", green: "#00ff00" } satisfies Colors;
console.log(palette.red.toUpperCase());
Checking Object Keys
satisfies is particularly useful for record objects where you want TypeScript to catch missing or misspelled keys against a required shape, without losing the ability to access each key's specific value type afterward.
Example: Checking Object Keys
type Routes = Record<"home" | "about", string>;
const routes = { home: "/", about: "/about" } satisfies Routes;
console.log(routes.about);
satisfies with Functions
A function-valued property can be checked with satisfies while the expression itself stays directly callable and usable exactly as written, unlike casting it with an explicit type annotation would.
Example: satisfies with Functions
type Handlers = Record<string, (x: number) => number>;
const handlers = {
double: (x: number) => x * 2,
} satisfies Handlers;
console.log(handlers.double(5));
satisfies vs Type Annotation
A type annotation tells TypeScript to treat a value as the declared type going forward, while satisfies only checks compatibility once and then lets the expression keep its own more specific inferred type.
Example: satisfies vs Type Annotation
type Config = { port: number };
const annotated: Config = { port: 8080 };
const satisfied = { port: 8080 } satisfies Config;
console.log(annotated.port, satisfied.port);
Chapter Quiz — Complete all 20 topics to unlock
0/20 topics done
Complete these topics first:
- TypeScript Advanced Types
- Mapped Types
- Conditional Types
- Custom Type Guards
- Assertion Functions
- Control Flow Analysis
- Exhaustiveness Checking
- Satisfies Operator
- Template Literal Types
- Utility Types - Partial
- Utility Types - Required
- Utility Types - Readonly
- Utility Types - Pick
- Utility Types - Omit
- Utility Types - Record
- Utility Types - Exclude and Extract
- Utility Types - NonNullable
- Utility Types - ReturnType
- Utility Types - Parameters
- TypeScript 5 Updates