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
Handle private access chained on an optional chain #11248
Handle private access chained on an optional chain #11248
Conversation
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 the most important comment: #11248 (comment)
...ugin-proposal-class-properties/test/fixtures/private/optional-chain-with-transform/output.js
Outdated
Show resolved
Hide resolved
packages/babel-helper-member-expression-to-functions/src/index.js
Outdated
Show resolved
Hide resolved
packages/babel-plugin-proposal-class-properties/test/fixtures/private/optional-chain/output.js
Outdated
Show resolved
Hide resolved
This is a mix of changes, most importantly: - Always print parens when mixing nullish coalescing and another logical - Fixes assignment in the callee of an optional chain, which now blocks babel#11248 Also, cleans up a bit of code, and removes an unnecessary parens around `class A extends new B {}`
This is a mix of changes, most importantly: - Always print parens when mixing nullish coalescing and another logical - Fixes assignment in the callee of an optional chain, which now blocks #11248 Also, cleans up a bit of code, and removes an unnecessary parens around `class A extends new B {}`
fa21565
to
54b2109
Compare
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.
Thanks!
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/22849/ |
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 6c4486f:
|
I am converting this PR to draft as transforming |
Whops I clicked "Approve" on the wrong PR |
4379f5c
to
b1b28b7
Compare
See the resolution from tc39/proposal-class-fields#301.
397d516
to
9635a42
Compare
packages/babel-helper-member-expression-to-functions/src/index.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
✅On changes by @jridgewell . But this PR needs approval other than myself on my changes. Thanks for @nicolo-ribaudo who inspires me on the |
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.
Thanks for figuring out the #m?.()
after I offered my help and then failed 😂
(_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : _classPrivateFieldLooseBase(fn().Foo, _self)[_self]) === null || _ref22 === void 0 ? void 0 : (_ref22$getSelf = _ref22.getSelf) === null || _ref22$getSelf === void 0 ? void 0 : _ref22$getSelf.call(_ref22)) === null || _getSelf6 === void 0 ? void 0 : _classPrivateFieldLooseBase(_getSelf6.self, _m)[_m](); | ||
(_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_classPrivateFieldLoo4 = _classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : _ref20.call(_classPrivateFieldLoo4)) === null || _call2 === void 0 ? void 0 : _classPrivateFieldLooseBase(_call2.self, _m)[_m](); | ||
(_getSelf5 = (_ref21 = fn === null || fn === void 0 ? void 0 : _classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref21.getSelf()) === null || _getSelf5 === void 0 ? void 0 : _classPrivateFieldLooseBase(_getSelf5.self, _m)[_m](); | ||
(_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : _classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf6 === void 0 ? void 0 : _classPrivateFieldLooseBase(_getSelf6.self, _m)[_m](); |
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.
In the future we'll figure out how to use == null
here.
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.
We could add loose
support to
export default function memberExpressionToFunctions(path, visitor, state) { |
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.
@jridgewell some fantastic code comments in this PR!
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com> Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
See the resolution from tc39/proposal-class-fields#301.
We intend to allow devs to access private properties in the optional chains, eg
foo?.bar.#baz
. We're still debating whether to allow the private property to start the optional chain, egfoo?.#baz
.--- Edits By @JLHwung ---
Todo list tracking
?. PrivateIdentifier
supportfoo?.#x
foo?.#m()
foo.#m?.()
foo?.#m?.()