-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Use 'Reflect.defineProperty' instead of 'Object.defineProperty' #6832
Conversation
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
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.
Semantically, Reflect
is intended to be used from Proxy
traps. You're supposed to return
the result of Reflect.defineProperty
from a default defineProperty
Proxy
trap.
I'm not sure you should be using it in non-Proxy
-related code.
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.
I changed my mind on this one (thanks @Kovensky for pointing this out).
The difference between Reflect and Object.defineProperty is that Object.defineProperty
throws if the operation fails. (Reflect.defineProperty
returns false)
So what's the behavior we want here? In my opinion we want an error to be thrown if the property can't be defined. An error here indicates that something is wrong here. We don't want this to be silently ignored...
@ooflorent Thanks for your update. I labeled the Pull Request so reviewers will review it again. @sokra Please review the new changes. |
Thanks |
What kind of change does this PR introduce?
refactoring
Did you add tests for your changes?
no
If relevant, link to documentation update:
n/a
Summary
Reflect.defineProperty
is more meaningful thanObject.defineProperty
. InternallyReflect.dP
performs less checks thanObject.dP
.Use
Object.defineProperty
Does this PR introduce a breaking change?
no