Skip to content

[MUI v7] "@mui/material/styles" has no exported member named 'ThemeProviderProps' #45700

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mtr1990 opened this issue Mar 27, 2025 · 7 comments · Fixed by #45701
Closed

[MUI v7] "@mui/material/styles" has no exported member named 'ThemeProviderProps' #45700

mtr1990 opened this issue Mar 27, 2025 · 7 comments · Fixed by #45701
Assignees
Labels
package: material-ui Specific to @mui/material typescript

Comments

@mtr1990
Copy link

mtr1990 commented Mar 27, 2025

Steps to reproduce

Missing ThemeProviderProps exported in '@mui/material/styles'

https://stackblitz.com/edit/github-41iztrt1?file=src%2FThemeProvider.tsx

Current behavior

This works in MUI v6. But missing in MUI v7

in packages/mui-material/src/styles/index.d.ts

export { default as ThemeProvider } from './ThemeProvider';

Expected behavior

export { default as ThemeProvider } from './ThemeProvider';
export * from './ThemeProvider';

Context

No response

Your environment

No response

Search keywords: ThemeProviderProps

@mtr1990 mtr1990 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 27, 2025
@mtr1990 mtr1990 changed the title [v7] '"@mui/material/styles"' has no exported member named 'ThemeProviderProps'. [MUI v7] "@mui/material/styles" has no exported member named 'ThemeProviderProps'. Mar 27, 2025
@mtr1990 mtr1990 changed the title [MUI v7] "@mui/material/styles" has no exported member named 'ThemeProviderProps'. [MUI v7] "@mui/material/styles" has no exported member named 'ThemeProviderProps' Mar 27, 2025
@aarongarciah
Copy link
Member

aarongarciah commented Mar 27, 2025

While we check this, you can import it from @mui/material/styles/ThemeProvider.

import { ThemeProviderProps } from '@mui/material/styles/ThemeProvider';

@aarongarciah aarongarciah removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 27, 2025
@aarongarciah aarongarciah added typescript package: material-ui Specific to @mui/material labels Mar 27, 2025
@aarongarciah
Copy link
Member

aarongarciah commented Mar 27, 2025

@mtr1990 looks like ThemeProviderProps was not exported from @mui/material/styles in v6 either. See https://stackblitz.com/edit/github-41iztrt1-udtzafwu?file=src/ThemeProvider.tsx. I also tested locally, since StackBlitz TS is buggy sometimes.

@mnajdova
Copy link
Member

While we check this, you can import it from @mui/material/styles/ThemeProvider.

This will not work with ESM, no? We need to export it from @mui/material/styles.

@mtr1990
Copy link
Author

mtr1990 commented Mar 27, 2025

Currently I am configuring in tsconfig.json with moduleResolution": "bundler

import type { ThemeProviderProps } from '@mui/material/styles/ThemeProvider';

=> This doesn't work in MUI v7 but works in MUI v6

When I changed the config in tsconfig.json with moduleResolution": "node,
import type { ThemeProviderProps } from '@mui/material/styles/ThemeProvider';

=> It works. The question here is moduleResolution": "node is really required?

Same as other import types:

- import type { CommonColors } from '@mui/material/styles/createPalette';
- import type { Channels, PaletteColor } from '@mui/material/styles/createPalette';
...

=> Means the sub items imported after @mui/material/styles/... are not working with moduleResolution": "bundler
=> Doesn't work in moduleResolution": "bundler but works with moduleResolution": "node

@aarongarciah
Copy link
Member

aarongarciah commented Mar 27, 2025

As @mnajdova said, we need to export it from @mui/material/styles for it to work with ESM (v7). I'll open a PR.

Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@aarongarciah
Copy link
Member

@mtr1990 the fix is merged and it will land in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: material-ui Specific to @mui/material typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants