TypeScript `satisfies` vs `as`

as lies. satisfies checks.

const palette = {
  green: '#034c3c',
  orange: '#ec4e20',
} as Record<string, string>;
// palette.green is now `string` — we lost the literal type.

const palette2 = {
  green: '#034c3c',
  orange: '#ec4e20',
} satisfies Record<string, string>;
// palette2.green is `'#034c3c'` — literal preserved AND shape verified.

Use satisfies when you want the literal types kept and the shape checked. Use as only when you genuinely know more than the compiler — and almost never on object literals.

0%