Skip to content
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

Error in @mui/system: Modules ./typography and others have no exported member default #43685

Closed
morozow opened this issue Sep 9, 2024 · 7 comments
Labels
package: system Specific to @mui/system typescript

Comments

@morozow
Copy link
Contributor

morozow commented Sep 9, 2024

Steps to reproduce

Link to live example: local dev as there's no TS completion to build live phase

Description:

  1. When attempting to build a TypeScript project that imports from @mui/system, the TypeScript compiler throws the following error:
node_modules/@mui/system/typography/index.d.ts:1:10 - error TS2305: Module '"./typography"' has no exported member 'default'.

1 export { default } from './typography';

Steps to Reproduce

  1. Install the latest version of @mui/system via yarn or follow a Default Installation - Material UI
  2. Set up a TypeScript project that imports @mui/system.
  3. Run the TypeScript compiler.

The same issue with:

  • Module ./borders...
  • Module ./cssGrid...
  • Module ./display...
  • Module ./flexbox...
  • Module ./palette...
  • Module ./positions...
  • Module ./shadows...
  • Module ./sizing...
  • Module ./spacing...
  • Module ./style...
  • Module ./typography...

Current behavior

The TypeScript compiler fails with a TS2305 error indicating that index.d.ts incorrectly attempts to export a non-existent default member from ./typography.

 error TS2305: Module '"./typography"' has no exported member 'default'.

1 export { default } from './typography';

Expected behavior

The TypeScript compiler should complete without errors, allowing for the proper usage of the @mui/system package components.

Context

Additional Context

  • Node.js version: v20.9.0
  • yarn version: 1.22.19
  • TypeScript version: 5.6.2
  • MUI System version: 6.0.2

Your environment

npx @mui/envinfo

  System:
    OS: macOS 14.1.1
  Binaries:
    Node: 20.9.0 - /usr/local/bin/node
    npm: 10.2.4 - /usr/local/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 128.0.6613.120
    Edge: Not Found
    Safari: 17.1
  npmPackages:
    @emotion/react: ^11.13.3 => 11.13.3 
    @emotion/styled: ^11.13.0 => 11.13.0 
    @mui/core-downloads-tracker:  6.0.2 
    @mui/envinfo: ^2.0.25 => 2.0.25 
    @mui/icons-material: ^6.0.2 => 6.0.2 
    @mui/material: ^6.0.2 => 6.0.2 
    @mui/private-theming:  6.0.2 
    @mui/styled-engine:  6.0.2 
    @mui/styles: ^6.0.2 => 6.0.2 
    @mui/system:  6.0.2 
    @mui/types:  7.2.16 
    @mui/utils:  6.0.2 
    @mui/x-date-pickers: ^7.16.0 => 7.16.0 
    @mui/x-internals:  7.16.0 
    @types/react: ^18.3.5 => 18.3.5 
    react: ^18.3.1 => 18.3.1 
    react-dom: ^18.3.1 => 18.3.1 
    typescript: ^5.6.2 => 5.6.2 


Search keywords: error, types, d.ts

@morozow morozow added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 9, 2024
@morozow
Copy link
Contributor Author

morozow commented Sep 9, 2024

Nitpick: If anyone encounters this issue, here is a quick fix for Unix systems using Yarn post-install:

#!/bin/bash
cd ./

find . -type f -name "*.d.ts" -exec sed -i'' -e 's#export = dayjs;*#export default dayjs;#g' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/borders'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/cssGrid'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/display'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/flexbox'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/palette'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/positions'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/sizing'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/spacing'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/style'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e '/export { default } from '\''\.\/typography'\'';/d' {} +
find . -type f -name "index.d.ts" -exec sed -i'' -e 's#export { default } from '\''\.\/shadows'\'';*#export * from '\''\.\/shadows'\'';#g' {} +

Smth like this into package.json:

...
"scripts": {
    "postinstall": "bash ./bin/post.install.sh",
}
...

That works also for a new age "@mui/x-date-pickers": "^7.16.0",

@siriwatknp
Copy link
Member

siriwatknp commented Sep 10, 2024

Are you using @mui/system directly? Usually, @mui/system is not required to be installed explicitly if you use Material UI (it's already a dependency)

If you need more help, please provide a CodeSandbox or a repo that we can take a look.

@siriwatknp siriwatknp added status: waiting for author Issue with insufficient information package: system Specific to @mui/system and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 10, 2024
@morozow
Copy link
Contributor Author

morozow commented Sep 10, 2024

No, I don’t directly use @mui/system. Upon reviewing my package.json, the only dependencies listed are "@mui/icons-material": "^6.0.2", "@mui/material": "^6.0.2", "@mui/styles": "^6.0.2", and "@mui/x-date-pickers": "^7.16.0", with "@mui/envinfo": "^2.0.25" included in devDependencies. It appears that @mui/envinfo aggregates all dependencies independently of package.json. Therefore, the foregoing solution is currently the only fix from my local perspective. Any suggestions? Following a GitHub implementation, it indeed looks like the default export is missing. What could be the reason for this export?

Details:

Comparison of suitable imports:

Nitpick: object type may not be the most suitable here. Consider using unknown or any other generic type that more accurately represents the value

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Sep 10, 2024
@morozow
Copy link
Contributor Author

morozow commented Sep 10, 2024

Here are my 2 cents on automating deployment while the above issue remains unresolved: #43700 (comment)

morozow added a commit to morozow/material-ui that referenced this issue Sep 11, 2024
Replaced all default exports with named exports to improve module consistency and tree-shaking capabilities. This change ensures uniform export style across the codebase and aids in better maintainability and IDE auto-completion.

Bug Report: mui#43685
@morozow
Copy link
Contributor Author

morozow commented Sep 11, 2024

This Pull Request eliminates undefined exports: #43702

Please review it and let me know if there are any additional contributions or changes needed.

Additional note: currently in dev phase as vita has an exception while built

@siriwatknp siriwatknp added typescript and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 11, 2024
@morozow
Copy link
Contributor Author

morozow commented Sep 16, 2024

The problem has been fixed by updating the documentation: #43747

@morozow morozow closed this as completed Sep 16, 2024
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.

Note

We value your feedback @morozow! How was your experience with our support team?
If you could spare a moment, we'd love to hear your thoughts in this brief Support Satisfaction survey. Your insights help us improve!

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

No branches or pull requests

2 participants