til / typescript-satisfies-operator
[ ]

$ TypeScript satisfies operator preserves literal types

The satisfies operator validates that an expression matches a type while preserving its inferred type:

// With 'as const', you get literal types but lose type checking
const config = {
  endpoint: '/api/users',
  timeout: 5000,
} as const;

// With 'satisfies', you get both type checking AND literal types
const config = {
  endpoint: '/api/users',
  timeout: 5000,
} satisfies Config;

// Now TypeScript knows:
// - config.endpoint is exactly '/api/users' (not just string)
// - config.timeout is exactly 5000 (not just number)
// - AND it validates against Config interface

Use satisfies when you want type safety without losing the precision of literal types.