-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Pagination] Leverage @default
over default values
#19966
[Pagination] Leverage @default
over default values
#19966
Conversation
No bundle size changes comparing 41fe2e2...e242671 |
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.
Interesting! It could potentially be used for a couple of other components, the Autocomplete for instance :).
The only point that I wonder about is how does this "direction" affects moving the descriptions of the prop-types in TypeSript?
We probably want to do this at some point anyway. Then we need to be more careful with throwing an error if we find both (probably just verify they're equal). In any case: the default value in the typescript types would be a nice to have. |
Co-Authored-By: Olivier Tassinari <olivier.tassinari@gmail.com>
35011cb
to
e242671
Compare
Will be reverted in #22447. The problem is that it's not accurate. The default value in the component for |
OT, but speaking of direction, am I the only one that feels that the current direction for sharing prop descriptions is "backwards"? I routinely edit the component prop descriptions first, so then have to sync them manually, since the script assumes that the type definitions is the singe source of truth. Class names go in the opposite direction. |
Purely technical decision. TypeScript declarations have very different shapes to accomodate certain patterns. Figuring out where to put the description is incredibly hard. Same for classes: This would be slightly easier to figure out where the description goes in the JS file but would still need flow analysis. In TypeScript it's currently a single pattern: A type property with name Since this is all driven by "routine" I don't think it's worth putting time into it. Sure, a single file would be better (though I'd personally never do this since it discourages extensive documentation). But I feel like we have pretty clear messaging what went wrong with documentation and how to fix it. |
Makes sense, thanks. |
Using runtime for documentation can be quite confusing. Let's solve docs concerns with jsdoc instead. Both approaches can just as easily become outdated. But the new one doesn't add noise to the implementation.
yarn docs:api
will throw if you use a default value and@default
in the propTypes even if they have the same value e.g.will throw: