I am trying to access a nested object structure using object keys, but TypeScript gives me the error:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type...
My color themes object structure is as follows:
colors: {
background: string;
text: string;
black: string;
white: string;
yellow: {
100: string;
200: string;
300: string;
400: string;
500: string;
600: string;
700: string;
800: string;
900: string;
};
green: {
100: string;
... 7 more ...;
900: string;
};
red: {
...;
};
cyan: {
...;
};
purple: {
...;
};
gray: {
...;
};
}
But when I am accessing the color, it shows me the error. Please help. I am not able to access the themes.colors[color][weight]
Error:
