When working with TypeScript, I have a union literal type named Color
defined as:
export type Color =
| 'red'
| 'green'
| 'blue'
| 'teal'
| 'purple'
My challenge is to define the type of a dictionary where some of the keys are from the values of Color
, and the values are strings.
For example:
const COLOR_MAP = {
red: 'Cool',
green: 'Not so cool'
}
I need to create a type for COLOR_MAP
so that I can access its values using a string that matches the type Color
.