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

[core] Fix prop-types generation #38831

Merged
merged 3 commits into from
Sep 11, 2023

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Sep 6, 2023

See #38517 (comment) for more context

All the problematic component should not correctly be generated, except the slider slots (but for me that's normal)

@mui-bot
Copy link

mui-bot commented Sep 6, 2023

Netlify deploy preview

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

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 6ecd2e5

@flaviendelangle flaviendelangle marked this pull request as draft September 6, 2023 12:40
@flaviendelangle flaviendelangle force-pushed the fix-proptypes branch 2 times, most recently from 172e348 to a17b4b7 Compare September 6, 2023 13:13
}

// handle component factories: x = createComponent()
if (
checkDeclarations &&
node.initializer &&
!isStyledFunction(node) &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before getJSXLikeReturnValueFromFunction did not recognize React.ReactNode as a valid JSX response, so styled components were ignored.

Now they are supported, but we probably don't want them to be so I added a test to filter them out.

@@ -0,0 +1,29 @@
// eslint-disable-next-line no-restricted-imports -- importing types
import { InternalStandardProps as StandardProps } from '@mui/material';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name was wrong (tsx instead of ts) so the props were considered external (maybe we could loosen the implementedBySelfPropsFile variable in generateProptypes

scripts/generateProptypes.ts Show resolved Hide resolved
// Any components that are created by a factory function, e.g. System Box | Container | Grid.
getFromProp(node);
} else {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow to handle nested react.memo(react.forwardRef(...))

@@ -250,14 +265,13 @@ function getPropsFromVariableDeclaration({
});
}
}

return null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that we test the createX pattern for all components, otherwise we might miss some

@flaviendelangle flaviendelangle self-assigned this Sep 6, 2023
@flaviendelangle flaviendelangle added the core Infrastructure work going on behind the scenes label Sep 6, 2023
@flaviendelangle flaviendelangle marked this pull request as ready for review September 6, 2023 13:48
@michaldudak
Copy link
Member

All right, it works great now for me.
Since the Slider slots' prop types are not generated, could you remove them?

@flaviendelangle
Copy link
Member Author

@michaldudak done 👌

@flaviendelangle flaviendelangle merged commit cda1ffe into mui:master Sep 11, 2023
@flaviendelangle flaviendelangle deleted the fix-proptypes branch September 11, 2023 10:20
xcode-it pushed a commit to xcode-it/material-ui that referenced this pull request Sep 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants