Skip to content

[material-ui][Alert] Can't set slots in theme's defaultProps in 5.15.11 #41322

@andrei-shoreline

Description

@andrei-shoreline

Steps to reproduce

Steps:

  1. Create a custom theme using createTheme
  2. Configure MuiAlert component:
const theme = createTheme({
  components: {
    MuiAlert: {
      defaultProps: {
        slots: {
          closeIcon: CloseRounded,
        },
      },
    },
  },
});

Current behavior

TypeScript gives the following error:

Object literal may only specify known properties, but 'slots' does not 
exist in type 'Partial<AlertProps>'. Did you mean to write 'slot'?

Expected behavior

It shouldn't throw an error and it should work the same as in the previous 5.15.10 version.

Context

In our application we customised the default theme using the createTheme utility.

Your environment

npx @mui/envinfo
  System:
    OS: macOS 14.3.1
  Binaries:
    Node: 20.11.1 - /opt/homebrew/opt/nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - /opt/homebrew/opt/nvm/versions/node/v20.11.1/bin/npm
    pnpm: Not Found
  npmPackages:
    @emotion/react: 11.11.4 => 11.11.4
    @emotion/styled: 11.11.0 => 11.11.0
    @mui/base:  5.0.0-beta.37
    @mui/core-downloads-tracker:  5.15.11
    @mui/icons-material: 5.15.11 => 5.15.11
    @mui/lab: 5.0.0-alpha.166 => 5.0.0-alpha.166
    @mui/material: 5.15.11 => 5.15.11
    @mui/private-theming:  5.15.11
    @mui/styled-engine:  5.15.11
    @mui/system:  5.15.11
    @mui/types:  7.2.13
    @mui/utils:  5.15.11
    @mui/x-data-grid: 6.19.5 => 6.19.5
    @mui/x-date-pickers: 6.19.5 => 6.19.5
    @types/react: 18.2.61 => 18.2.61
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: 5.3.3 => 5.3.3

Search keywords: Alert, slots, 5.15.11

Metadata

Metadata

Assignees

Labels

scope: alertChanges related to the alert.type: regressionA bug, but worse, it used to behave as expected.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions