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

[bugfix] Refactor prop types generation and add import optimisation #43736

Conversation

morozow
Copy link
Contributor

@morozow morozow commented Sep 12, 2024

Add type annotations to enhance the robustness of prop type generation. Introduce a new optimiseImports function to standardise import formats. Implement an optimise command for removing unnecessary imports in declaration files.

Replaced all occurrences of import PropTypes from 'prop-types'; with import * as PropTypes from 'prop-types'; in the Material UI codebase related to @mui/utils

Bug Report: [Error] Incorrect Import of PropTypes Causes Compilation Error

This represents an initial step towards a solution for the TypeScript tsc compiler

This improvement offers a viable solution for the tsc compiler by organising utility functions across all files. While handling internal refactoring of just built/generated files may seem impractical, it’s worth considering. It appears there are more adaptable solutions, but they often generate incorrect outputs for TypeScript, as previously mentioned #43701, #43701 (comment), #43701 (comment). Notably, the prop-types package remains unchanged. Therefore, this proposal represents the initial step in addressing the tsc compiler issue.

Add type annotations to enhance the robustness of prop type generation. Introduce a new `optimiseImports` function to standardize import formats. Implement an `optimise` command for removing unnecessary imports in declaration files.
@morozow morozow changed the title [bugfix] Refactor prop types generation and add import optimization [bugfix] Refactor prop types generation and add import optimisation Sep 12, 2024
Correct the example file name in the comment to reflect the proper '.d.ts' extension, ensuring clarity and accuracy for future reference. No functional changes made; purely a documentation update.
@zannager zannager added the package: material-ui Specific to @mui/material label Sep 13, 2024
@zannager zannager requested a review from Janpot September 13, 2024 10:03
Renamed and refactored optimisation functions for clarity. Introduced distinct handling commands for optimizing PropTypes and TypeScript declaration files. Added error logging and better pattern matching in both command handlers.
@morozow
Copy link
Contributor Author

morozow commented Sep 16, 2024

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

@morozow morozow closed this Sep 16, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants