Last active
July 26, 2023 08:06
-
-
Save mayognaise/1b256a0063edf62d00f22e79722bfa68 to your computer and use it in GitHub Desktop.
Create a union type from object key
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
const colors = { | |
bg: '#e5e5e5', | |
navy: '#002b45', | |
orange: '#fb5a3b', | |
darkOrange: '#cf4d34', | |
} as const | |
type ColorKey = keyof typeof colors // "navy" | "orange" | "bg" | "darkOrange" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment