Skip to content

Instantly share code, notes, and snippets.

@mayognaise
Created July 26, 2023 08:10
Show Gist options
  • Save mayognaise/0164657deb155fe865ef09b4cf6e6088 to your computer and use it in GitHub Desktop.
Save mayognaise/0164657deb155fe865ef09b4cf6e6088 to your computer and use it in GitHub Desktop.
Create a union type from object value
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