I am working with Material UI with TypeScript and want to add custom colors to my theme. Everything is working fine, except the VSCode linter that show me the next message.
Type '{ tan: string; lightRed: string; red: string; offBlack: string; white: string; }' is not assignable to type 'Partial<CommonColors>'.
Object literal may only specify known properties, and 'tan' does not exist in type 'Partial<CommonColors>'.
In terms of develop and build is working fine, the only complain is the error message. I add a custom type to try to solve but it is not working.
const theme = createTheme({
palette: {
common: {
tan,
lightRed,
red,
offBlack,
white,
},
},
});
import {
PaletteOptions,
CommonColors,
} from '@material-ui/core/styles/createPalette';
interface CustomColors extends CommonColors {
tan: string?;
lightRed: string;
red: string;
offBlack: string;
}
declare module '@material-ui/core/styles/createPalette' {
export interface PaletteOptions {
common: CustomColors;
}
}
I added to the tsconfig.json file. The tan, red and the rest of values are declared as Strings. Any clue about how can I solve this? Thanks in advance.