Estoy tratando de extender la paleta MUI para poder usar mis propias propiedades con nombre con el siguiente código:
declare module '@mui/material/styles' { interface Palette { border: Palette['primary'] background: Palette['primary'] } // allow configuration using `createTheme` interface PaletteOptions { border?: PaletteOptions['primary'] background?: PaletteOptions['primary'] } } border funciona sin problemas, sin embargo, al intentar agregar un nuevo fondo, se queja de este.
Error completo:
Property 'primary' does not exist on type 'TypeBackground'. TS2339 8 | 9 | const DocumentUploadContainer = styled('div')` > 10 | color: ${props => props.theme.palette.background.primary}; | ^ 11 | ` 12 | export const Documents = () => { 13 | return (Puede verificar en el archivo createPalette.d.ts de mui. Porque background ya está en interface PaletteOptions (como puede ver aquí)
export interface PaletteOptions { primary?: PaletteColorOptions; secondary?: PaletteColorOptions; error?: PaletteColorOptions; warning?: PaletteColorOptions; info?: PaletteColorOptions; success?: PaletteColorOptions; mode?: PaletteMode; tonalOffset?: PaletteTonalOffset; contrastThreshold?: number; common?: Partial<CommonColors>; grey?: ColorPartial; text?: Partial<TypeText>; divider?: string; action?: Partial<TypeAction>; background?: Partial<TypeBackground>; getContrastText?: (background: string) => string; } export interface TypeBackground { default: string; paper: string; }Por lo tanto, no puede usar el aumento de módulos para anularlo de esta manera. Solo usa otro nombre.