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
Evaluate object and initializer when setting a private method #12707
Conversation
packages/babel-helper-create-class-features-plugin/src/fields.js
Outdated
Show resolved
Hide resolved
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/43268/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8388185:
|
...es/babel-plugin-proposal-private-methods/test/fixtures/private-method/reassignment/output.js
Outdated
Show resolved
Hide resolved
...el-plugin-proposal-private-methods/test/fixtures/private-method-loose/reassignment/output.js
Show resolved
Hide resolved
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.
Can we add a test case for an accessor without a set
?
@JLHwung Could you rebase this? 🙏 |
@@ -14,7 +14,7 @@ class Cl { | |||
value: 0 | |||
}); | |||
|
|||
babelHelpers.readOnlyError("#privateFieldValue"); | |||
this, 1, babelHelpers.readOnlyError("#privateFieldValue"); |
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 a few more unnecessary bytes, but this path will always result in an error so it's highly improbable that it will happen in production code.
I rewrote the title to keep it short enough while still adding info about the last two commits. |
Pass down
value
to the argument ofclassPrivateMethodSet
so it will always be evaluated before a runtime error is thrown.