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.
const routes = {
home: "/",
library: "/library",
} satisfies Record<string, `/${string}`>;
routes.library; // type is "/library", not string