I have styled components and typescript in my RN Project
Typescript is throwing a weird error in one of my files, it says Element implicitly has 'any' type because expression of type 'string' can't be used to index 'ColorKeyType'
The affected code, the error is at the return theme.colors[color]
part
const StyledText = styled(Text)<TextStyleProps>` color: ${({ color, theme }) => { if (color) { return theme.colors[color] || color; } return theme.colors.text; }}`;
My theme color is typed like:
interface ColorKeyType { primary: string; ... more colors like the one above}
then I use the type like:
{ colors: ColorKeyType; fonts: { families: { primary: { [key in FontFamilyType]: string }; }; fontSize: { [key in FontSizeType]: number }; letterSpacing: number; };}
Thanks in advance for any possible solutions!