Skip to content

Instantly share code, notes, and snippets.

@bagaskarala
Created January 2, 2024 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagaskarala/e945b69bf2049e1258ec1190eb47f4ee to your computer and use it in GitHub Desktop.
Save bagaskarala/e945b69bf2049e1258ec1190eb47f4ee to your computer and use it in GitHub Desktop.
Typescript snippets
// annotation - keep wide
const scores: Record<string,number> = {}
scores.maths = 99 // no autocomplete
// satisfies - keep narrow
const configs = {
width: '100px',
isDark: true
} satisfies Record<string, string | boolean>
// configs.width = 200 // invalid
configs.width = '200px'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment