Created
January 16, 2026 04:24
-
-
Save pfftdammitchris/c32fbf91a86b664063a85c528322df4b to your computer and use it in GitHub Desktop.
The Power of TypeScript's Satisfies Operator - snippet-23.ts
This file contains hidden or 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
| // Before: Type annotation causes widening | |
| const theme: Record<string, string> = { | |
| primary: '#3b82f6', | |
| secondary: '#10b981', | |
| } | |
| // Later in code, you might see type guards like this | |
| if ('primary' in theme) { | |
| // Unnecessary check | |
| // ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment