Skip to content

Instantly share code, notes, and snippets.

@pfftdammitchris
Created January 16, 2026 04:25
Show Gist options
  • Select an option

  • Save pfftdammitchris/8243fcc01419ff315dc160c7c8b92947 to your computer and use it in GitHub Desktop.

Select an option

Save pfftdammitchris/8243fcc01419ff315dc160c7c8b92947 to your computer and use it in GitHub Desktop.
The Power of TypeScript's Satisfies Operator - snippet-3.ts
type ThemeColors = Record<'primary' | 'secondary' | 'danger', string>
const theme = {
primary: '#3b82f6',
secondary: '#10b981',
danger: '#ef4444',
} satisfies ThemeColors
// Validation: TypeScript ensures all required keys exist
// Inference: TypeScript still knows the exact literal values
theme.primary // Type is '#3b82f6' (not just 'string')
theme.primry // Error! Typo caught
theme.warning // Error! Key not in the original object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment