question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createMuiTheme getting "Object literal may only specify known properties"

See original GitHub issue

Providing custom variables to createMuiTheme gives the error “Object literal may only specify known properties”.

"@material-ui/core": "^4.9.9",
"@material-ui/icons": "^4.9.1",
"@material-ui/lab": "^4.0.0-alpha.48",
"@material-ui/pickers": "^3.2.10",
"@material-ui/styles": "^4.9.6",

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
WillSquirecommented, Jun 5, 2020

@eps1lon Thanks for reopening.

@oliviertassinari For this particular case or in general? For this case I’d probably add something like this with a link to customization-of-theme to find out more:

import { createMuiTheme } from '@material-ui/core/styles';
import { Theme } from '@material-ui/core/styles/createMuiTheme';
import purple from '@material-ui/core/colors/purple';
import green from '@material-ui/core/colors/green';

// Override Mui's theme typings to include the new theme property
declare module '@material-ui/core/styles/createMuiTheme' {
  interface Theme {
    status: {
      danger: React.CSSProperties['color'],
    }
  }
  interface ThemeOptions {
    status?: {
      danger?: React.CSSProperties['color']
    }
  }
}

const theme = createMuiTheme({
  palette: {
    primary: purple,
    secondary: green,
  },
  status: {
    danger: 'orange',
  },
})

If that helps?

3reactions
eps1loncommented, Jun 4, 2020

Your issue has been closed because it does not conform to our issue requirements.

For how-to questions and other non-issues, please use Spectrum.chat or StackOverflow instead of Github issues. There is a StackOverflow tag called “material-ui” that you can use to tag your questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

createMuiTheme getting "Object literal may only specify ...
Providing custom variables to createMuiTheme gives the error "Object literal may only specify known properties".
Read more >
Why am I getting an error "Object literal may only specify ...
As of TypeScript 1.6, properties in object literals that do not have a corresponding property in the type they're being assigned to are...
Read more >
Object literal may only specify known properties in TS
The "Object literal may only specify known properties" error occurs when a property in an object literal does not exist in the object's...
Read more >
Extend Material-UI theme in TypeScript - In Plain English
Object literal may only specify known properties, and 'success' does not exist in type 'PaletteOptions'. It means that because Material-UI ...
Read more >
can't resolve '@material-ui/core/styles/createmuitheme'
Providing custom variables to createMuiTheme gives the error "Object literal may only specify known properties". "@material-ui/core": "^4.9 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found