I’m trying to create a strict mapping for a theme, but I want the keys of the mapping, not to be dynamic, but have optional values for the keys. Meaning the key type of “100 | AppBackground” can have one of those keys and the same value. Here are some of the things I have tried. I always want to allow strict key value pairs like red:color
.
type 300 = '300' | 'CardBackground';
export type ThemeMapping = {
[key: '100' | 'AppBackground']: Color;
[key in '200' | 'ContentBackground']: Color;
[key: 300 ]: Color;
['400' | 'InactiveBackground']: Color;
link: Color;
red: Color;
yellow: Color;
green: Color;
blue: Color;
}
I know for dynamic values you can also do {[key: string]: Color}
. I just want the key type to essentially be options rather than dynamic or just a regular string.
Please let me know if you need me to explain more.