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

[Fix] prop-types: className missing in prop validation #3749

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akulsr0
Copy link
Contributor

@akulsr0 akulsr0 commented May 6, 2024

Closes #3284

@@ -634,6 +634,8 @@ module.exports = function propTypesInstructions(context, components, utils) {
// So we should construct an optional children prop
this.shouldSpecifyOptionalChildrenProps = true;

this.shouldSpecifyClassNameProp = true;
Copy link
Member

Choose a reason for hiding this comment

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

why do we need a class property for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since react generic type would have className too

Copy link
Member

Choose a reason for hiding this comment

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

what i mean is, when is this not always true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So whenever the type is coming from react import reference, then we can have className too (similar to children).
When its not true is: type annotation, type literal, etc...

Copy link
Member

Choose a reason for hiding this comment

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

className is just a prop, though, like any other. I'm a bit confused why it merits special treatment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

className is a react specific prop for HTML elements. class is a vanilla HTML attribute.

Copy link
Member

Choose a reason for hiding this comment

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

Sure, that's all true - but HTML elements don't use propTypes, so we're only talking about custom components here.

Copy link

codecov bot commented May 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.60%. Comparing base (4467db5) to head (21ba4c5).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3749      +/-   ##
==========================================
- Coverage   97.71%   97.60%   -0.12%     
==========================================
  Files         133      133              
  Lines        9470     9473       +3     
  Branches     3469     3470       +1     
==========================================
- Hits         9254     9246       -8     
- Misses        216      227      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Typescript "'className' is missing in props validation" despite being defined
2 participants