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