Skip to content

Instantly share code, notes, and snippets.

@mayognaise
Last active July 26, 2023 08:06
Show Gist options
  • Save mayognaise/1b256a0063edf62d00f22e79722bfa68 to your computer and use it in GitHub Desktop.
Save mayognaise/1b256a0063edf62d00f22e79722bfa68 to your computer and use it in GitHub Desktop.
Create a union type from object key
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