Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save pfftdammitchris/fb045e48a27b25881377bad299040e97 to your computer and use it in GitHub Desktop.
The Power of TypeScript's Satisfies Operator - snippet-9.ts
type Endpoint = {
url: string
method: 'GET' | 'POST'
}
const endpoints = {
getUsers: { url: '/users', method: 'GET' },
createUser: { url: '/users', method: 'POST' },
// Forgot an endpoint? TypeScript can help if you use a stricter type
} satisfies Record<string, Endpoint>
// Later, you get full autocomplete
fetch(endpoints.getUsers.url) // '/users' - literal type!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment