Doing It Wrong

learn in public

Site Navigation

  • Home
  • Books
  • Work & Play

Site Search

You are here: Home / 2026 / Archives for August 2026

Archives for August 2026

Understanding `satisfies`

posted on August 19, 2026

satisfies solves a tension that annotations can’t: you want TypeScript to check a value against a type, but you don’t want it to forget what it inferred about that value. An annotation does the first and loses the second. satisfies does the first and keeps the second.

// RGB-only Palette
type namedColor = "red" | "green" | "blue";
type RGB = [number, number, number];
type Palette = Record<namedColor, RGB | string>;

// With Annotation
const paletteAnnotated: Palette = {
  red: [255, 0, 0],
  green: "00ff00",
  blue: "0000ff",
};

paletteAnnotated.green.toUpperCase(); // Property 'toUpperCase' does not exist on type 'RGB'.

// With Only Inference
const paletteInferred = {
  red: [255, 0, 0],
  green: "00ff00",
  blueu: [0, 0], // intentional typo AND not a parseable color
};

paletteInferred.green.toUpperCase(); // This now works...

// With `satisfies`!
const paletteSatisfies = {
  red: [255, 0, 0],
  green: "00ff00",
  blue: "0000ff",
} satisfies Palette;

paletteSatisfies.red.map((color) => +color);
paletteSatisfies.green.toUpperCase();

Code language: TypeScript (typescript)

Filed Under: Development

Profile Links

  • GitHub
  • Buy Me a Coffee?

Recent Posts

  • Understanding `satisfies`
  • Event Listeners
  • A Philosophy of Software Design
  • The Programmer’s Brain
  • Thoughts on Microservices

Recent Comments

No comments to show.

Archives

  • August 2026
  • May 2025
  • September 2024
  • July 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • December 2022
  • December 2021

Categories

  • Development