TypeScript: satisfies vs as
April 8, 2025
Use satisfies when you want to validate a value matches a type without widening it. Use as when you need to override the compiler.
// `as` loses the literal types
const routes = {
home: "/",
about: "/about",
} as Record<string, string>;
routes.home; // string - literal "/" is lost
// `satisfies` keeps them
const routes = {
home: "/",
about: "/about",
} satisfies Record<string, string>;
routes.home; // "/" - literal type preserved
The rule of thumb: reach for satisfies first. Only use as when you genuinely know more than the compiler.