I'm trying to solve a typescript error regarding the chosen color on my slider component:
<Slider
color="brown"
/>
The error is: Type '"brown"' is not assignable to type '"primary" | "secondary" | undefined'.
I have set the brown color on my theme, by augmenting the createPalette file.
declare module '@mui/material/styles/createPalette' {
interface Palette {
brown: PaletteColor
}
interface PaletteOptions {
brown: PaletteColorOptions
}
}
So now that I still have the error I looked in the Slider.d.ts file and found an interface: SliderPropsColorOverrides.
export interface SliderPropsColorOverrides {}
...
color?: OverridableStringUnion<'primary' | 'secondary', SliderPropsColorOverrides>;
I try to merge it with my brown color:
declare module '@mui/material/Slider' {
interface SliderPropsColorOverrides {
darkest_blue: PaletteColorOptions
}
}
But with no luck. Either my IDE (PhpStorm 2021.3) isn't compiling the new typescript code, or I'm missing something.