I have a type which looks like this
export type Theme = | 'primary'
| 'secondary'
| 'success'
| 'danger'
| 'warning'
| 'info'
| 'dark'
| 'light'
Now, i am creating a mapping where I want the keys be same as the ones in the theme, So i tried this but this keeps on throwing following error
const colorMapping: { [key: Theme]: string } = {
primary: '#0275d8',
success: '#5cb85c'
}
An index signature parameter type cannot be a union type. Consider using a mapped object type instead
Can someone please help me in figuring out how I can fix this error?