Created
January 2, 2024 16:08
-
-
Save bagaskarala/e945b69bf2049e1258ec1190eb47f4ee to your computer and use it in GitHub Desktop.
Typescript snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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