-
Notifications
You must be signed in to change notification settings - Fork 107
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
isPrivate/isStatic probably shouldn't be prefixed with "is" #417
Comments
I don't know why the authors chose function decorator(value, { name, private: isPrivate, static: isStatic }) {
// ...
} |
I'd like to bump this issue to make sure it gets some attention before implementation starts in stage 3. I can understand if the committee decides to make an exception for property-names-that-would-otherwise-be-keywords, but if so that kind of precedent should be established willingly, not accidentally. So, for example, it's worth thinking about what happens if a third boolean property is added to these descriptors, that is not a keyword: do you use |
A good analogy that might help supporting this request is connecting these booleans with the property descriptors, also connected to a property. |
In any case, my position here is neutral. I understand the goal for consistency and avoiding a new precedent and for that I'd be very supportive to avoiding the |
I don't have a strong opinion here myself, while I think the benefit of |
With my developer hat on, I would strongly expect boolean flags to have no When using them from the options argument, I would prefer to have developers either not use destructuring (e.g., |
Given these flags only apply to class elements, would it be helpful to rename them to Clearly, these names are less ergonomic; but, I wonder if they might help some people avoid attempting to use them with decorators intended to be called on classes or other JavaScript syntax forms (excluding class elements). |
That implies they contain the element, as opposed to a boolean describing them. |
Good point. |
The proposal got stage 3 without this issue arising again, and therefore with the current I personally totally forgot about this issue, and I suspect I was not the only one. I apologize. I'm hoping to raise this explicitly before this meeting is over (proposing to change it to |
We discussed this further in plenary and decided to update to |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Was it really worth losing destructuring simplicity here? I have never been confused by |
Just mentioning that I end up always writing I bet millions that no one has blindly assumed It wasn't necessary to remove |
So far there's weak precedent in JavaScript specs and broader-but-with-exceptions precedent in web specs that "is" prefixes are reserved for functions asking questions about their arguments, and we don't use them otherwise. https://w3ctag.github.io/design-principles/#naming-booleans
Examples:
Functions asking questions about their arguments:
Number.isNaN(arg)
,Array.isArray(arg)
.Properties asking questions about their this value:
regExp.multiline
,temporalDate.inLeapYear
,event.cancelable
. (event.isTrusted
is a notable exception on the web.)An options argument being used as input into a spec-defined function: not sure of any ES precedents, but on the web we use
new Event(type, { cancelable: true })
, which makes sense to match the previous bullet (i.e. it'd be strange if you passed inisX
as an argument and then had to consult thex
property).This spec is actually about an options argument being used as input to a user-defined function, which I'm not sure if we have any precedent for even on the web. But I think it makes sense to align with the general trend toward omitting "is" prefixes except in the functions-asking-question-about-their-arguments case.
The text was updated successfully, but these errors were encountered: