Skip to content
gitrep
Library

41fe8c6snippet1 min read

The satisfies operator

Check a value against a type without widening it, so you keep precise literal types.

Published

A type annotation replaces the inferred type. satisfies checks against a type and keeps the inferred one.

ts
const routes = {
  home: "/",
  library: "/library",
} satisfies Record<string, `/${string}`>;

routes.library; // type is "/library", not string
  1. Discriminated unions in practiceModel state as a set of explicit cases so the compiler tells you every place a new case needs handling.Article