Handle private access chained on an optional chain#11248
Conversation
There was a problem hiding this comment.
This is the most important comment: #11248 (comment)
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
|
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
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 |
nicolo-ribaudo
left a comment
There was a problem hiding this comment.
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.
In the future we'll figure out how to use == null here.
There was a problem hiding this comment.
We could add loose support to
existentialism
left a comment
There was a problem hiding this comment.
@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
?. PrivateIdentifiersupportfoo?.#xfoo?.#m()foo.#m?.()foo?.#m?.()