Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

475
Visualizações
Material-UI v5 - typing createTheme not working per docs

I'm working through this resource from MUI. Despite my efforts, and looking through other similar posts on Stackoverflow, I can't get theme to behave. I'm using the verbatim instructions from the guide yet it's still showing a typescript error.

error:

Argument of type '{ status: { danger: "#ff9800"; }; }' is not assignable to parameter of type 'ThemeOptions'.
  Object literal may only specify known properties, and 'status' does not exist in type 'ThemeOptions'.

src/index.tsx

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";

import { createTheme, ThemeProvider } from "@mui/material/styles";

const root = ReactDOM.createRoot(
  document.getElementById("root") as HTMLElement
);

const theme = createTheme({
  // type error appears here
  status: {
    danger: orange[500],
  },
});

root.render(
  <React.StrictMode>
    <ThemeProvider theme={theme}>
      <App />
    </ThemeProvider>
  </React.StrictMode>
);

root - material-ui.d.ts.

declare module "@mui/material/styles" {
  export interface Theme {
    status: {
      danger: string;
    };
  }
  // allow configuration using `createTheme`
  export interface ThemeOptions {
    status?: {
      danger?: string;
    };
  }
}

My assumption is that the theme that createTheme is using is going to reference the update module. Doesn't seem to be happening. Is material-ui.d.ts not the right location? Any ideas?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda