-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs] Enable synthetic default imports in TypeScript config #43747
Conversation
Added `allowSyntheticDefaultImports` to TypeScript configuration for better compatibility with CommonJS modules. This helps to simplify imports and improves integration with various libraries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems reasonable. Thank you!
… doc/tsc-documentatiion-fix
@Janpot I’ve partially tested a solution to comply with a GitHub build checks as I do not have permissions to re-run. However, I haven’t found any information on how to run the |
@Janpot It seems that the markdown hasn't been deployed to the website https://mui.com/material-ui/guides/typescript/. The documentation link points to a corrected version yet the production still shows an outdated default |
To avoid having documentation online for unreleased features, we only deploy the docs when we publish a new release. It will be live on the next release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have learned a few things here:
- Doing
esModuleInterop
actually setallowSyntheticDefaultImports
esModuleInterop does not implicitly enable allowSyntheticDefaultImports microsoft/TypeScript#26193 - If we
import React from 'react';
from https://github.com/morozow/material-ui-tsc-fix reproduction, we have the same problem but a different error message:
1 import React from 'react';
~~~~~node_modules/.pnpm/@types[email protected]/node_modules/@types/react/index.d.ts:46:1
46 export = React;
~~~~~~~~~~~~~~~
This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
- Because the error is clearer, making this change [prop-types] Fix export DefinitelyTyped/DefinitelyTyped#70539 makes sense, it allows a better DX in the worst case scenario.
Added
allowSyntheticDefaultImports
to TypeScript configuration for better compatibility with CommonJS modules. This helps to simplify imports and improves integration with various libraries.Fix #43700