-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Dont repeat full object names where possible #4083
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
Conversation
|
||
export const action = PropTypes.oneOf([ | ||
const FuncReq = func.isRequired | ||
const StrReq = StrReq |
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.
shouldn't this read const StrReq = string.isRequired
?
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.
search & replace. Fixed now.
@@ -1,48 +1,50 @@ | |||
import { PropTypes } from 'react' | |||
const {func, string, any, oneOf, shape} = PropTypes |
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.
Nit: Add spaces inside of the brackets. That's consistent with how we normally write destructurings.
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.
if we're gonna nit on this stuff I suppose we should put it in the eslint config.
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.
Yeah, it's come up a couple times before. I can get that added.
just curious, what's the size change? |
@ryanflorence embarrassingly small (like .5k or so). This was more as a sodlace when I realized that #4046 wasn't going to happen |
Is the .5k really worth it? Seems like it's complicating the PropTypes file for a really tiny gain. |
I can understand destructing the PropTypes variable, but is the func.isRequired -> funqReq really necessary? After minification aren't we looking at a difference of 10's of characters? |
I've confirmed that my bundle size decreases by .5k
I think that's subjective. Personally, I'd love to drop every single byte that I can.
I appreciate not minifying code at the expense of readability. I think that propType-like variables are pretty obvious to most. I wouldn't necessarily rename methods or classnames on the basis of minification, and the exported values are quite self documenting. I do agree that a babel-transform to do this work at build time would be preferable. I do not know of any that can do that for us though. I should point out that most libs wouldn't have to deal with this issue as they can strip out propTypes at build time (which was the original motivation here). However libraries that use context may wish to take this extra step. |
I'd rather not worry about micro stuff like this right now, trying to ship this and get it right first. |
A tiny size gainz for PropTypes