Skip to content

[icons] fix: correct the exported types for "@mui/icons-material" index path on v7 #45695

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

Conversation

laurence-hudson-mindfoundry

While upgrading from v6 to v7 I noticed that the type information seems to be wrong for the index path of "@mui/icons-material". Locally I'm using Typescript 5.5.4, transpiling to both CJS & ESM.

This probably slipped through v7 testing as using the recommended ("option 1" in the docs) icon import pattern (i.e. import AccessAlarmIcon from '@mui/icons-material/AccessAlarm';) wouldn't catch this, but using the named export pattern fails (ie. import { AccessAlarm } from '@mui/icons-material';) as it gets icon.d.ts typing instead of index.d.ts.

This fix seems to work locally, but I'm not a TS/ESM packaging wizard.

@mui-bot
Copy link

mui-bot commented Mar 26, 2025

Netlify deploy preview

https://deploy-preview-45695--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against e8caadc

@laurence-hudson-mindfoundry
Copy link
Author

It is unclear to me how/why this test https://github.com/mui/material-ui/blob/master/packages/mui-icons-material/test/generated-types/Test.tsx would be working without this fix; given it tests both import styles, possibly typescript version differences or esm vs cjs?

@mnajdova mnajdova requested a review from Janpot March 26, 2025 19:12
@Janpot
Copy link
Member

Janpot commented Mar 26, 2025

@laurence-hudson-mindfoundry please open a ticket with an exact reproduction under the form of a GitHub repository or stackblitz so that we can investigate

@laurence-hudson-mindfoundry
Copy link
Author

laurence-hudson-mindfoundry commented Mar 26, 2025

@laurence-hudson-mindfoundry please open a ticket with an exact reproduction under the form of a GitHub repository or stackblitz so that we can investigate

Here you go https://stackblitz.com/edit/mui7-ts-icons?file=package.json

#45697

@laurence-hudson-mindfoundry
Copy link
Author

I spent a little while exploring the attw failure in my suggested fix, but couldn't find a permutation that both works in practice and passes attw.

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

Successfully merging this pull request may close these issues.

4 participants