After dabbling in TypeScript for React Native, I've encountered some rather strange error messages that have me stumped.
While experimenting with my code, I came across this line:
<Text text={user?.last_name} style={{color:colors.textSecondary}} variant="labelMedium"/>
Visual Studio Code is flagging an issue with colors.textSecondary:
Property 'textSecondary' does not exist on type '{ primary: string; background: string; card: string; text: string; border: string; notification: string; }'.ts(2339)
Surprisingly, using colors.text works just fine, and I'm puzzled as to why. Here's the snippet from the theme file where I'm defining the standard theme colors:
export const Theme = {
light: {
mode: 'light',
colors: {
primary: '#1976d2',
secondary: '#7393B3',
background: '#f9f9f9',
card: '#ffffff',
text: '#303233',
textSecondary: '#727272',
border: '#e8e8e8',
error: '#f44336',
},
},
dark: {
mode: 'dark',
colors: {
primary: '#1976d2',
secondary: '#7393B3',
background: '#171819',
card: '#202122',
text: '#e4e6eb',
textSecondary: '#b0b3b8',
border: '#333435',
error: '#f44336',
},
},
};
Where could I be going wrong here? Strangely enough, the text color displays correctly despite the error.
Thanks! Jan