---
title: "The satisfies operator: type-check a value without losing its literal types"
description: "Learn how the TypeScript satisfies operator checks a value against a type while keeping its precise inferred type, and when to reach for it instead of annotations or as."
url: https://www.danny.engineering/article/the-satisfies-operator-type-check-a-value-without-losing-its-literal-types
author: Danny
published: 2026-11-27T00:00:00.000Z
updated: 2026-11-27T17:23:00.000Z
tags: ["Typescript"]
---

# The satisfies operator: type-check a value without losing its literal types

You have an object full of settings, routes or colours. You want TypeScript to tell you when you misspell a key or forget one. You also want the editor to know that one value is a string and another is a tuple, so you can call the right methods on each. With a plain type annotation you only get the first. With no annotation you only get the second.


The `satisfies` operator, added in TypeScript 4.9, gives you both. This article is for anyone who writes TypeScript day to day and has ever fought an annotation that made a value less useful than it was before. We will start with the problem, look at what `satisfies` actually does, and finish with the patterns where it earns its place.


## The problem with type annotations


Here is a small palette. Each colour can be a hex string or an RGB tuple.


```typescript
type Colour = "red" | "green" | "blue";
type RGB = [number, number, number];
type Palette = Record<Colour, string | RGB>;

const palette: Palette = {
  red: [255, 0, 0],
  green: "#00ff00",
  blue: [0, 0, 255],
};

palette.green.toUpperCase();
// Error: Property 'toUpperCase' does not exist on type 'string | RGB'.
```


The annotation did its job of checking the object. But it also replaced the type TypeScript inferred with the declared type. Now every property is `string | RGB`, even though you can see that `green` is a string. You end up writing extra checks or casts for information the compiler already had.


## The problem with no annotation


Remove the annotation and inference gives you precise types back.


```typescript
const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
  bleu: [0, 0, 255],
};

palette.green.toUpperCase(); // fine
```


The catch is the typo. `bleu` slipped through, and nothing warns you that `blue` is missing. You find out later, usually at runtime, when something reads `palette.blue` and gets `undefined`.


## What satisfies does


`satisfies` sits after an expression and checks that the expression is assignable to a type. Unlike an annotation, it does not change the type of the expression. The value keeps its inferred type, and the target type is used only for checking and for contextual typing.


```typescript
const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
  blue: [0, 0, 255],
} satisfies Palette;

palette.green.toUpperCase(); // fine: green is a string
palette.red.at(0);           // fine: red is an RGB tuple
```


And the mistakes are caught again:


```typescript
const palette = {
  red: [255, 0, 0],
  green: "#00ff00",
  bleu: [0, 0, 255],
} satisfies Palette;
// Error: Object literal may only specify known properties,
// and 'bleu' does not exist in type 'Palette'.
```


If you remove `blue` entirely, you get an error saying the property is missing. If you write `red: [255, 0]`, you get an error because a two-item array is not an `RGB`.


Notice that `red` is inferred as a tuple, not as `number[]`. That is the contextual typing part: TypeScript uses `Palette` as a hint while inferring the literal, so arrays and string literals are inferred in a shape that fits the target. You get the precision of inference and the shape of the type you asked for.


A useful way to remember the difference:

- An annotation says "this variable has this type".
- `satisfies` says "this value must fit this type, but keep what you know about it".

## satisfies is not as


It is easy to confuse `satisfies` with a type assertion, because both appear after an expression. They do opposite jobs.


```typescript
type User = { id: string; name: string };

const a = {} as User;        // compiles, and a is now a lie
const b = {} satisfies User; // Error: missing properties 'id' and 'name'
```


`as` tells the compiler to trust you. It only refuses when the two types have nothing in common. `satisfies` asks the compiler to check you. If you have been using `as` on object literals to get autocomplete, `satisfies` is almost always the safer swap.


## Combining satisfies with as const


`as const` makes a literal deeply read-only and keeps every value as its narrowest literal type. On its own, it checks nothing. Put the two together and you get literal types that are also validated.


```typescript
const routes = {
  home: "/",
  articles: "/articles",
  article: "/article/:id",
} as const satisfies Record<string, `/${string}`>;

type RouteName = keyof typeof routes;
// "home" | "articles" | "article"

const path = routes.article;
// type is "/article/:id", not string
```


The template literal type in the constraint means every value must start with a slash. Write `"articles"` without one and you get an error on that property. The order matters: `as const` applies first, then `satisfies` checks the read-only result.


## Real-world uses


### Lookup tables that must cover every case


A `Record` keyed by a union forces you to handle every member. With `satisfies`, each entry keeps its own precise type.


```typescript
type Status = "draft" | "review" | "published";

const statusLabel = {
  draft: { text: "Draft", tone: "neutral" },
  review: { text: "In review", tone: "warning" },
  published: { text: "Published", tone: "success" },
} satisfies Record<Status, { text: string; tone: "neutral" | "warning" | "success" }>;
```


Add `"archived"` to `Status` and this object fails to compile until you add a label. That turns a forgotten case into a build error rather than a blank badge in production.


### Configuration files


Many tools export a config type. Using `satisfies` on the default export checks your settings and keeps the literal values visible to anything that imports the config.


```typescript
import type { NextConfig } from "next";

const nextConfig = {
  reactStrictMode: true,
  images: {
    remotePatterns: [{ protocol: "https", hostname: "images.example.com" }],
  },
} satisfies NextConfig;

export default nextConfig;
```


An annotation would work just as well for the tool itself. The difference shows when your own code reads the object, for example a test that checks a specific setting.


### Deriving types from a checked value


Sometimes the value is the source of truth and the types should follow it. `satisfies` lets you check the value against a loose shape, then derive narrow types from it.


```typescript
type Handler = (payload: unknown) => void;

const handlers = {
  "user.created": (payload) => console.log("created", payload),
  "user.deleted": (payload) => console.log("deleted", payload),
} satisfies Record<string, Handler>;

type EventName = keyof typeof handlers;
// "user.created" | "user.deleted"

function dispatch(name: EventName, payload: unknown) {
  handlers[name](payload);
}
```


With an annotation of `Record<string, Handler>`, `keyof typeof handlers` would just be `string`, and `dispatch("user.updated", ...)` would compile. With `satisfies`, it does not. The parameters in each handler are also contextually typed as `unknown`, so you do not need to annotate them.


## What satisfies does not do


A few limits are worth knowing so you are not surprised.

- **It has no runtime effect.** Like every type construct, it is erased when your code is compiled or stripped. It will not validate data from an API, a form or a file. For that you need a runtime check, such as a schema library or a hand-written type guard.
- **Excess property checks only apply to fresh literals.** If you build an object elsewhere and then write `existing satisfies Palette`, extra properties are not reported, the same as with normal assignment.
- **It does not make anything read-only.** Mutating a property is still allowed unless you add `as const` or a `readonly` type.
- **It checks once, where it is written.** If you later reassign a `let` variable, the new value is checked against the variable's inferred type, not the `satisfies` target.

## Version support


`satisfies` arrived in TypeScript 4.9, released in November 2022, so any current TypeScript version supports it, including 6.0 and the native 7.0 compiler. Tools that strip types without checking them, such as esbuild, SWC, Babel and Node's built-in type stripping, all understand and remove it. Because it is erasable syntax, it is also allowed under the `erasableSyntaxOnly` compiler option.


If your editor or linter reports `satisfies` as a syntax error, the tool is bundling an older TypeScript version than your project. Updating the tool or pointing it at the workspace TypeScript fixes it.


## When not to use it


`satisfies` is not a replacement for every annotation. Reach for a plain annotation when:

- **You are typing function parameters and return types.** These are contracts for callers. An annotation is the clearest way to state them, and `satisfies` cannot be used on a parameter anyway.
- **You want the wider type on purpose.** If you export an object and do not want callers to depend on its exact current values, annotate it with the broad type. Literal types leak detail into your public API.
- **The variable will be reassigned.** A `let` that holds different values over time is better described by its declared type than by the type of its first value.
- **The value is already well typed.** Writing `satisfies string` after a string literal adds noise and nothing else.

A reasonable rule of thumb: use `satisfies` on object and array literals that are mostly read, especially configuration, lookup tables and maps of handlers. Use annotations at boundaries.


## Wrapping up

- An annotation checks a value but replaces its inferred type. `satisfies` checks the value and keeps what TypeScript inferred.
- `as` silences the compiler, `satisfies` asks it to check you. Prefer `satisfies` on object literals.
- `as const satisfies SomeType` gives you deeply literal, read-only values that are still validated.
- Pair it with a `Record` keyed by a union to turn forgotten cases into build errors.
- It is compile-time only, so untrusted data still needs runtime validation.
