-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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 object rest enumeration #29676
Fix object rest enumeration #29676
Conversation
When this PR lands, the same change should be made to |
2b646cd
to
bf12ce1
Compare
3332029
to
d1e5150
Compare
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable(p[i])) |
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.
This is incorrect as you are passing the wrong receiver. Its highly unlikely p[i]
is enumerable on Object.prototype
. You probably mean this:
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable(p[i])) | |
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) |
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.
Ah, makes sense. In that case, does s.propertyIsEnumerable(p[i])
work as well?
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.
On second thought, I suppose s
could have its own implementation of propertyIsEnumerable, so no, that probably does not work.
As @ajafff mentioned above, you should also open a PR against https://github.com/Microsoft/tslib for the same change: |
d1e5150
to
32bcd41
Compare
It looks like you still have some failing tests. |
…ent enumerable symbols from sneaking through.
32bcd41
to
61e1009
Compare
Yep, sorry. Fixed! |
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.
Looks good!
'Bug' or 'help wanted' or is in the Community milestone
master
branchjake runtests
locallyFixes #29616
Adjusts the __rest function in destructuring.ts to check if property is enumerable.