diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-noDocumentAll/basic/output.mjs b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-noDocumentAll/basic/output.mjs index aeb9a31d2c95..182e2dec8196 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-noDocumentAll/basic/output.mjs +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-noDocumentAll/basic/output.mjs @@ -1,5 +1,5 @@ var _fn, _a, _a2, _a2$b, _a$b, _a3; (_fn = fn) === null || _fn === void 0 ? void 0 : _fn(...b, 1); (_a = a) === null || _a === void 0 ? void 0 : _a.b(...c, 1); -(_a2 = a) === null || _a2 === void 0 ? void 0 : (_a2$b = _a2.b) === null || _a2$b === void 0 ? void 0 : _a2$b.call(_a2, ...c, 1); +(_a2 = a) === null || _a2 === void 0 || (_a2$b = _a2.b) === null || _a2$b === void 0 ? void 0 : _a2$b.call(_a2, ...c, 1); (_a$b = (_a3 = a).b) === null || _a$b === void 0 ? void 0 : _a$b.call(_a3, ...c, 1); diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js index cca610f6522e..02eede3e8b14 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js @@ -1,11 +1,11 @@ -var _foo, _foo2, _foo$bar, _foo3, _foo4, _foo4$bar, _foo5, _foo6, _foo7, _foo$bar2, _foo8, _foo$bar3, _foo9, _foo$bar3$call, _foo10, _foo10$bar, _foo11, _foo11$bar, _foo11$bar$call; +var _foo, _foo2, _foo$bar, _foo3, _foo4, _foo4$bar, _foo5, _foo6, _foo$bar2, _foo7, _foo$bar3, _foo8, _foo9, _foo9$bar, _foo10, _foo10$bar; (_foo = foo) === null || _foo === void 0 ? void 0 : _foo(...[], 1); (_foo2 = foo) === null || _foo2 === void 0 ? void 0 : _foo2.bar(...[], 1); (_foo$bar = (_foo3 = foo).bar) === null || _foo$bar === void 0 ? void 0 : _foo$bar.call(_foo3, foo.bar, ...[], 1); -(_foo4 = foo) === null || _foo4 === void 0 ? void 0 : (_foo4$bar = _foo4.bar) === null || _foo4$bar === void 0 ? void 0 : _foo4$bar.call(_foo4, foo.bar, ...[], 1); +(_foo4 = foo) === null || _foo4 === void 0 || (_foo4$bar = _foo4.bar) === null || _foo4$bar === void 0 ? void 0 : _foo4$bar.call(_foo4, foo.bar, ...[], 1); (_foo5 = foo) === null || _foo5 === void 0 ? void 0 : _foo5(...[], 1).bar; -(_foo6 = foo) === null || _foo6 === void 0 ? void 0 : (_foo7 = _foo6(...[], 1)) === null || _foo7 === void 0 ? void 0 : _foo7.bar; -(_foo$bar2 = (_foo8 = foo).bar) === null || _foo$bar2 === void 0 ? void 0 : _foo$bar2.call(_foo8, ...[], 1).baz; -(_foo$bar3 = (_foo9 = foo).bar) === null || _foo$bar3 === void 0 ? void 0 : (_foo$bar3$call = _foo$bar3.call(_foo9, ...[], 1)) === null || _foo$bar3$call === void 0 ? void 0 : _foo$bar3$call.baz; -(_foo10 = foo) === null || _foo10 === void 0 ? void 0 : (_foo10$bar = _foo10.bar) === null || _foo10$bar === void 0 ? void 0 : _foo10$bar.call(_foo10, ...[], 1).baz; -(_foo11 = foo) === null || _foo11 === void 0 ? void 0 : (_foo11$bar = _foo11.bar) === null || _foo11$bar === void 0 ? void 0 : (_foo11$bar$call = _foo11$bar.call(_foo11, ...[], 1)) === null || _foo11$bar$call === void 0 ? void 0 : _foo11$bar$call.baz; +(_foo6 = foo) === null || _foo6 === void 0 || (_foo6 = _foo6(...[], 1)) === null || _foo6 === void 0 ? void 0 : _foo6.bar; +(_foo$bar2 = (_foo7 = foo).bar) === null || _foo$bar2 === void 0 ? void 0 : _foo$bar2.call(_foo7, ...[], 1).baz; +(_foo$bar3 = (_foo8 = foo).bar) === null || _foo$bar3 === void 0 || (_foo$bar3 = _foo$bar3.call(_foo8, ...[], 1)) === null || _foo$bar3 === void 0 ? void 0 : _foo$bar3.baz; +(_foo9 = foo) === null || _foo9 === void 0 || (_foo9$bar = _foo9.bar) === null || _foo9$bar === void 0 ? void 0 : _foo9$bar.call(_foo9, ...[], 1).baz; +(_foo10 = foo) === null || _foo10 === void 0 || (_foo10$bar = _foo10.bar) === null || _foo10$bar === void 0 || (_foo10$bar = _foo10$bar.call(_foo10, ...[], 1)) === null || _foo10$bar === void 0 ? void 0 : _foo10$bar.baz; diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic-integration-optional-chaining/output.mjs b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic-integration-optional-chaining/output.mjs index 63d9046613ba..e4df9b09ef8c 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic-integration-optional-chaining/output.mjs +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic-integration-optional-chaining/output.mjs @@ -1,4 +1,4 @@ var _fn, _a, _a2, _a2$b; (_fn = fn) === null || _fn === void 0 ? void 0 : _fn(...b, 1); (_a = a) === null || _a === void 0 ? void 0 : _a.b(...c, 1); -(_a2 = a) === null || _a2 === void 0 ? void 0 : (_a2$b = _a2.b) === null || _a2$b === void 0 ? void 0 : _a2$b.call(_a2, ...c, 1); +(_a2 = a) === null || _a2 === void 0 || (_a2$b = _a2.b) === null || _a2$b === void 0 ? void 0 : _a2$b.call(_a2, ...c, 1); diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic/output.mjs b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic/output.mjs index aeb9a31d2c95..182e2dec8196 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic/output.mjs +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/basic/output.mjs @@ -1,5 +1,5 @@ var _fn, _a, _a2, _a2$b, _a$b, _a3; (_fn = fn) === null || _fn === void 0 ? void 0 : _fn(...b, 1); (_a = a) === null || _a === void 0 ? void 0 : _a.b(...c, 1); -(_a2 = a) === null || _a2 === void 0 ? void 0 : (_a2$b = _a2.b) === null || _a2$b === void 0 ? void 0 : _a2$b.call(_a2, ...c, 1); +(_a2 = a) === null || _a2 === void 0 || (_a2$b = _a2.b) === null || _a2$b === void 0 ? void 0 : _a2$b.call(_a2, ...c, 1); (_a$b = (_a3 = a).b) === null || _a$b === void 0 ? void 0 : _a$b.call(_a3, ...c, 1); diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private/output.mjs b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private/output.mjs index c745723807d3..9c2695257295 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private/output.mjs +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private/output.mjs @@ -5,6 +5,6 @@ class C { const o = null; const n = this; const p = o === null || o === void 0 ? void 0 : o.#m(...c, 1); - const q = n === null || n === void 0 ? void 0 : (_n$m = n.#m) === null || _n$m === void 0 ? void 0 : _n$m.call(n, ...c, 1); + const q = n === null || n === void 0 || (_n$m = n.#m) === null || _n$m === void 0 ? void 0 : _n$m.call(n, ...c, 1); } } diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-member-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-member-call-with-transform/output.js index 50987af28db0..486ec892fe9e 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-member-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-member-call-with-transform/output.js @@ -39,7 +39,7 @@ class Foo { (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref6.self, _m)[_m](); (_call = (_ref15 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? void 0 : _ref15.call(_babelHelpers$classPr2)) === null || _call === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call.self, _m)[_m](); (_getSelf2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref16.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf2.self, _m)[_m](); - (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref17.getSelf == null ? void 0 : _ref17.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf3.self, _m)[_m](); + (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref17.getSelf == null ? void 0 : _ref17.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf3.self, _m)[_m](); fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _m)[_m](); fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _m)[_m]().toString; fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _m)[_m]().toString(); @@ -58,7 +58,7 @@ class Foo { (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) === null || _ref12 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref12.self, _m)[_m](); (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : _ref20.call(_babelHelpers$classPr4)) === null || _call2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call2.self, _m)[_m](); (_getSelf5 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref21.getSelf()) === null || _getSelf5 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf5.self, _m)[_m](); - (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf6.self, _m)[_m](); + (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf6.self, _m)[_m](); } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-property-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-property-with-transform/output.js index d088557e9892..480651f8ea15 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-property-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-before-property-with-transform/output.js @@ -38,7 +38,7 @@ class Foo { (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref6.self, _x)[_x]; (_call = (_ref15 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? void 0 : _ref15.call(_babelHelpers$classPr2)) === null || _call === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call.self, _x)[_x]; (_getSelf2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref16.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf2.self, _x)[_x]; - (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref17.getSelf == null ? void 0 : _ref17.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf3.self, _x)[_x]; + (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref17.getSelf == null ? void 0 : _ref17.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf3.self, _x)[_x]; fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _x)[_x]; fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _x)[_x].toString; fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _x)[_x].toString(); @@ -57,7 +57,7 @@ class Foo { (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) === null || _ref12 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref12.self, _x)[_x]; (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : _ref20.call(_babelHelpers$classPr4)) === null || _call2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call2.self, _x)[_x]; (_getSelf5 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref21.getSelf()) === null || _getSelf5 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf5.self, _x)[_x]; - (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf6.self, _x)[_x]; + (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf6.self, _x)[_x]; } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-delete-property-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-delete-property-with-transform/output.js index 12a0e11c0583..54b1573cdb0d 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-delete-property-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-delete-property-with-transform/output.js @@ -5,7 +5,7 @@ class Foo { return this; } static test() { - var _deep$very$o, _babelHelpers$classPr, _babelHelpers$classPr2, _fnDeep$very$o, _babelHelpers$classPr3, _babelHelpers$classPr4, _ref, _ref2, _ref3, _ref3$self, _ref4, _ref5, _ref6, _ref7, _ref8, _ref8$call, _ref9, _ref9$getSelf, _ref10, _ref10$getSelf, _ref11, _ref12, _ref13, _ref13$self, _ref14, _ref15, _ref16, _ref17, _ref18, _ref18$call, _ref19, _ref19$getSelf, _ref20, _ref20$getSelf; + var _deep$very$o, _babelHelpers$classPr, _babelHelpers$classPr2, _fnDeep$very$o, _babelHelpers$classPr3, _babelHelpers$classPr4, _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref20; const o = { Foo: Foo }; @@ -24,32 +24,32 @@ class Foo { (_deep$very$o = deep == null ? void 0 : deep.very.o) === null || _deep$very$o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(_deep$very$o.Foo, _self)[_self].unicorn; o === null || o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].unicorn; o === null || o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self.unicorn; - (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : delete _ref.self.unicorn; - (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) == null ? true : delete _ref2.self.unicorn; - (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : (_ref3$self = _ref3.self) == null ? true : delete _ref3$self.self.unicorn; + (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || delete _ref.self.unicorn; + (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) == null || delete _ref2.self.unicorn; + (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref3 = _ref3.self) == null || delete _ref3.self.unicorn; o === null || o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf().unicorn; - (_ref4 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? true : delete _ref4.call(_babelHelpers$classPr).unicorn; - (_ref5 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : delete _ref5.getSelf().unicorn; - (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : _ref6.getSelf == null ? true : delete _ref6.getSelf().unicorn; - (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) == null ? true : delete _ref7.self.unicorn; - (_ref8 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? true : (_ref8$call = _ref8.call(_babelHelpers$classPr2)) == null ? true : delete _ref8$call.self.unicorn; - (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : (_ref9$getSelf = _ref9.getSelf()) == null ? true : delete _ref9$getSelf.self.unicorn; - (_ref10 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : _ref10.getSelf == null ? true : (_ref10$getSelf = _ref10.getSelf()) == null ? true : delete _ref10$getSelf.self.unicorn; + (_ref4 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null || delete _ref4.call(_babelHelpers$classPr).unicorn; + (_ref5 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || delete _ref5.getSelf().unicorn; + (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref6.getSelf == null || delete _ref6.getSelf().unicorn; + (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) == null || delete _ref7.self.unicorn; + (_ref8 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null || (_ref8 = _ref8.call(_babelHelpers$classPr2)) == null || delete _ref8.self.unicorn; + (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref9 = _ref9.getSelf()) == null || delete _ref9.self.unicorn; + (_ref10 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref10.getSelf == null || (_ref10 = _ref10.getSelf()) == null || delete _ref10.self.unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].unicorn; (_fnDeep$very$o = fnDeep == null ? void 0 : fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o.Foo, _self)[_self].unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self.unicorn; - (_ref11 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : delete _ref11.self.unicorn; - (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) == null ? true : delete _ref12.self.unicorn; - (_ref13 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : (_ref13$self = _ref13.self) == null ? true : delete _ref13$self.self.unicorn; + (_ref11 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || delete _ref11.self.unicorn; + (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) == null || delete _ref12.self.unicorn; + (_ref13 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref13 = _ref13.self) == null || delete _ref13.self.unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf().unicorn; - (_ref14 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr3 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? true : delete _ref14.call(_babelHelpers$classPr3).unicorn; - (_ref15 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : delete _ref15.getSelf().unicorn; - (_ref16 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : _ref16.getSelf == null ? true : delete _ref16.getSelf().unicorn; - (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) == null ? true : delete _ref17.self.unicorn; - (_ref18 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? true : (_ref18$call = _ref18.call(_babelHelpers$classPr4)) == null ? true : delete _ref18$call.self.unicorn; - (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : (_ref19$getSelf = _ref19.getSelf()) == null ? true : delete _ref19$getSelf.self.unicorn; - (_ref20 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : _ref20.getSelf == null ? true : (_ref20$getSelf = _ref20.getSelf()) == null ? true : delete _ref20$getSelf.self.unicorn; + (_ref14 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr3 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null || delete _ref14.call(_babelHelpers$classPr3).unicorn; + (_ref15 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || delete _ref15.getSelf().unicorn; + (_ref16 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref16.getSelf == null || delete _ref16.getSelf().unicorn; + (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) == null || delete _ref17.self.unicorn; + (_ref18 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null || (_ref18 = _ref18.call(_babelHelpers$classPr4)) == null || delete _ref18.self.unicorn; + (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref19 = _ref19.getSelf()) == null || delete _ref19.self.unicorn; + (_ref20 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref20.getSelf == null || (_ref20 = _ref20.getSelf()) == null || delete _ref20.self.unicorn; } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-in-function-param-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-in-function-param-with-transform/output.js index ddc98ce0491c..062fb9ac25a2 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-in-function-param-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-in-function-param-with-transform/output.js @@ -26,7 +26,7 @@ class Foo { function g(o, r = (_ref => (_ref = (() => o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf(), _m)[_m])()) == null ? void 0 : _ref())()) { return r; } - function h(fnDeep, r = ((_fnDeep$very$o$Foo, _fnDeep$very$o) => (_fnDeep$very$o$Foo = fnDeep == null ? void 0 : (_fnDeep$very$o = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo, _m)[_m]())()) { + function h(fnDeep, r = ((_fnDeep$very$o$Foo, _fnDeep$very$o) => (_fnDeep$very$o$Foo = fnDeep == null || (_fnDeep$very$o = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo, _m)[_m]())()) { return r; } function i(fn, r = ((_getSelf, _ref2) => (_getSelf = (_ref2 = (() => fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self])()) == null ? void 0 : _ref2.getSelf()) === null || _getSelf === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf.self, _m)[_m]())()) { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-member-optional-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-member-optional-call-with-transform/output.js index 301c156e846f..04a72cb3744d 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-member-optional-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-member-optional-call-with-transform/output.js @@ -42,7 +42,7 @@ class Foo { (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) === null || _ref6 === void 0 ? void 0 : (_babelHelpers$classPr41 = (_babelHelpers$classPr42 = babelHelpers.classPrivateFieldLooseBase(_ref6.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr41.call(_babelHelpers$classPr42); (_call = (_ref18 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr5 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? void 0 : _ref18.call(_babelHelpers$classPr5)) === null || _call === void 0 ? void 0 : (_babelHelpers$classPr43 = (_babelHelpers$classPr44 = babelHelpers.classPrivateFieldLooseBase(_call.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr43.call(_babelHelpers$classPr44); (_getSelf2 = (_ref19 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref19.getSelf()) === null || _getSelf2 === void 0 ? void 0 : (_babelHelpers$classPr45 = (_babelHelpers$classPr46 = babelHelpers.classPrivateFieldLooseBase(_getSelf2.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr45.call(_babelHelpers$classPr46); - (_getSelf3 = (_ref20 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref20.getSelf == null ? void 0 : _ref20.getSelf()) === null || _getSelf3 === void 0 ? void 0 : (_babelHelpers$classPr47 = (_babelHelpers$classPr48 = babelHelpers.classPrivateFieldLooseBase(_getSelf3.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr47.call(_babelHelpers$classPr48); + (_getSelf3 = (_ref20 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref20.getSelf == null ? void 0 : _ref20.getSelf()) === null || _getSelf3 === void 0 ? void 0 : (_babelHelpers$classPr47 = (_babelHelpers$classPr48 = babelHelpers.classPrivateFieldLooseBase(_getSelf3.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr47.call(_babelHelpers$classPr48); fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr49 = (_babelHelpers$classPr50 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _m))[_m]) == null ? void 0 : _babelHelpers$classPr49.call(_babelHelpers$classPr50); fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr51 = (_babelHelpers$classPr52 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _m))[_m]) == null ? void 0 : _babelHelpers$classPr51.call(_babelHelpers$classPr52).toString; fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr53 = (_babelHelpers$classPr54 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _m))[_m]) == null ? void 0 : _babelHelpers$classPr53.call(_babelHelpers$classPr54).toString(); @@ -61,7 +61,7 @@ class Foo { (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) === null || _ref12 === void 0 ? void 0 : (_babelHelpers$classPr73 = (_babelHelpers$classPr74 = babelHelpers.classPrivateFieldLooseBase(_ref12.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr73.call(_babelHelpers$classPr74); (_call2 = (_ref26 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr10 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : _ref26.call(_babelHelpers$classPr10)) === null || _call2 === void 0 ? void 0 : (_babelHelpers$classPr75 = (_babelHelpers$classPr76 = babelHelpers.classPrivateFieldLooseBase(_call2.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr75.call(_babelHelpers$classPr76); (_getSelf5 = (_ref27 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref27.getSelf()) === null || _getSelf5 === void 0 ? void 0 : (_babelHelpers$classPr77 = (_babelHelpers$classPr78 = babelHelpers.classPrivateFieldLooseBase(_getSelf5.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr77.call(_babelHelpers$classPr78); - (_getSelf6 = (_ref28 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref28.getSelf == null ? void 0 : _ref28.getSelf()) === null || _getSelf6 === void 0 ? void 0 : (_babelHelpers$classPr79 = (_babelHelpers$classPr80 = babelHelpers.classPrivateFieldLooseBase(_getSelf6.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr79.call(_babelHelpers$classPr80); + (_getSelf6 = (_ref28 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref28.getSelf == null ? void 0 : _ref28.getSelf()) === null || _getSelf6 === void 0 ? void 0 : (_babelHelpers$classPr79 = (_babelHelpers$classPr80 = babelHelpers.classPrivateFieldLooseBase(_getSelf6.self, _m))[_m]) == null ? void 0 : _babelHelpers$classPr79.call(_babelHelpers$classPr80); } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-member-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-member-call-with-transform/output.js index 17f95275923b..170044186258 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-member-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-member-call-with-transform/output.js @@ -6,7 +6,7 @@ class Foo { return this; } static test() { - var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classPr, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classPr2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classPr3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classPr4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref9$self, _ref10, _ref11, _ref12, _ref13, _ref14, _ref14$call, _ref15, _ref15$getSelf, _ref16, _ref16$getSelf, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref19$self, _ref20, _ref21, _ref22, _ref23, _ref24, _ref24$call, _ref25, _ref25$getSelf, _ref26, _ref26$getSelf; + var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classPr, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classPr2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classPr3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classPr4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26; const o = { Foo: Foo }; @@ -27,41 +27,41 @@ class Foo { (_o$Foo = o == null ? void 0 : o.Foo) === null || _o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo, _m)[_m](); (_o$Foo2 = o == null ? void 0 : o.Foo) === null || _o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo2, _m)[_m]().toString; (_o$Foo3 = o == null ? void 0 : o.Foo) === null || _o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo3, _m)[_m]().toString(); - (_deep$very$o$Foo = deep == null ? void 0 : (_deep$very$o = deep.very.o) == null ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo, _m)[_m](); - (_deep$very$o$Foo2 = deep == null ? void 0 : (_deep$very$o2 = deep.very.o) == null ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo2, _m)[_m]().toString; - (_deep$very$o$Foo3 = deep == null ? void 0 : (_deep$very$o3 = deep.very.o) == null ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo3, _m)[_m]().toString(); + (_deep$very$o$Foo = deep == null || (_deep$very$o = deep.very.o) == null ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo, _m)[_m](); + (_deep$very$o$Foo2 = deep == null || (_deep$very$o2 = deep.very.o) == null ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo2, _m)[_m]().toString; + (_deep$very$o$Foo3 = deep == null || (_deep$very$o3 = deep.very.o) == null ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo3, _m)[_m]().toString(); (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) === null || _ref === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref, _m)[_m](); (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) === null || _ref2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref2, _m)[_m](); (_self2 = (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref7.self) === null || _self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self2, _m)[_m](); (_self3 = (_ref8 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) == null ? void 0 : _ref8.self) === null || _self3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self3, _m)[_m](); - (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : (_ref9$self = _ref9.self) == null ? void 0 : _ref9$self.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self, _m)[_m](); + (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref9 = _ref9.self) == null ? void 0 : _ref9.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self, _m)[_m](); (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) === null || _ref3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref3, _m)[_m](); (_call = (_ref10 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? void 0 : _ref10.call(_babelHelpers$classPr)) === null || _call === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call, _m)[_m](); (_getSelf = (_ref11 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref11.getSelf()) === null || _getSelf === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf, _m)[_m](); - (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref12.getSelf == null ? void 0 : _ref12.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf2, _m)[_m](); + (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref12.getSelf == null ? void 0 : _ref12.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf2, _m)[_m](); (_self4 = (_ref13 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) == null ? void 0 : _ref13.self) === null || _self4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self4, _m)[_m](); - (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? void 0 : (_ref14$call = _ref14.call(_babelHelpers$classPr2)) == null ? void 0 : _ref14$call.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self, _m)[_m](); - (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : (_ref15$getSelf = _ref15.getSelf()) == null ? void 0 : _ref15$getSelf.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self, _m)[_m](); - (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref16.getSelf == null ? void 0 : (_ref16$getSelf = _ref16.getSelf()) == null ? void 0 : _ref16$getSelf.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self2, _m)[_m](); + (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null || (_ref14 = _ref14.call(_babelHelpers$classPr2)) == null ? void 0 : _ref14.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self, _m)[_m](); + (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref15 = _ref15.getSelf()) == null ? void 0 : _ref15.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self, _m)[_m](); + (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref16.getSelf == null || (_ref16 = _ref16.getSelf()) == null ? void 0 : _ref16.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self2, _m)[_m](); (_fn$Foo = fn == null ? void 0 : fn().Foo) === null || _fn$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo, _m)[_m](); (_fn$Foo2 = fn == null ? void 0 : fn().Foo) === null || _fn$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo2, _m)[_m]().toString; (_fn$Foo3 = fn == null ? void 0 : fn().Foo) === null || _fn$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo3, _m)[_m]().toString(); - (_fnDeep$very$o$Foo = fnDeep == null ? void 0 : (_fnDeep$very$o = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo, _m)[_m](); - (_fnDeep$very$o$Foo2 = fnDeep == null ? void 0 : (_fnDeep$very$o2 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo2, _m)[_m]().toString; - (_fnDeep$very$o$Foo3 = fnDeep == null ? void 0 : (_fnDeep$very$o3 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo3, _m)[_m]().toString(); + (_fnDeep$very$o$Foo = fnDeep == null || (_fnDeep$very$o = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo, _m)[_m](); + (_fnDeep$very$o$Foo2 = fnDeep == null || (_fnDeep$very$o2 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo2, _m)[_m]().toString; + (_fnDeep$very$o$Foo3 = fnDeep == null || (_fnDeep$very$o3 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo3, _m)[_m]().toString(); (_ref4 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) === null || _ref4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref4, _m)[_m](); (_ref5 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) === null || _ref5 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref5, _m)[_m](); (_self5 = (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref17.self) === null || _self5 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self5, _m)[_m](); (_self6 = (_ref18 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) == null ? void 0 : _ref18.self) === null || _self6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self6, _m)[_m](); - (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : (_ref19$self = _ref19.self) == null ? void 0 : _ref19$self.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self2, _m)[_m](); + (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref19 = _ref19.self) == null ? void 0 : _ref19.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self2, _m)[_m](); (_ref6 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref6, _m)[_m](); (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr3 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : _ref20.call(_babelHelpers$classPr3)) === null || _call2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call2, _m)[_m](); (_getSelf3 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref21.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf3, _m)[_m](); - (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf4, _m)[_m](); + (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf4, _m)[_m](); (_self7 = (_ref23 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) == null ? void 0 : _ref23.self) === null || _self7 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self7, _m)[_m](); - (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : (_ref24$call = _ref24.call(_babelHelpers$classPr4)) == null ? void 0 : _ref24$call.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self2, _m)[_m](); - (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : (_ref25$getSelf = _ref25.getSelf()) == null ? void 0 : _ref25$getSelf.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self3, _m)[_m](); - (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref26.getSelf == null ? void 0 : (_ref26$getSelf = _ref26.getSelf()) == null ? void 0 : _ref26$getSelf.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self4, _m)[_m](); + (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null || (_ref24 = _ref24.call(_babelHelpers$classPr4)) == null ? void 0 : _ref24.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self2, _m)[_m](); + (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref25 = _ref25.getSelf()) == null ? void 0 : _ref25.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self3, _m)[_m](); + (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref26.getSelf == null || (_ref26 = _ref26.getSelf()) == null ? void 0 : _ref26.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self4, _m)[_m](); } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-property-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-property-with-transform/output.js index 247c30ac934a..b83442592f1e 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-property-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/optional-chain-optional-property-with-transform/output.js @@ -5,7 +5,7 @@ class Foo { return this; } static test() { - var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classPr, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classPr2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classPr3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classPr4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref9$self, _ref10, _ref11, _ref12, _ref13, _ref14, _ref14$call, _ref15, _ref15$getSelf, _ref16, _ref16$getSelf, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref19$self, _ref20, _ref21, _ref22, _ref23, _ref24, _ref24$call, _ref25, _ref25$getSelf, _ref26, _ref26$getSelf; + var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classPr, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classPr2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classPr3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classPr4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref23, _ref24, _ref25, _ref26; const o = { Foo: Foo }; @@ -26,41 +26,41 @@ class Foo { (_o$Foo = o == null ? void 0 : o.Foo) === null || _o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo, _x)[_x]; (_o$Foo2 = o == null ? void 0 : o.Foo) === null || _o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo2, _x)[_x].toString; (_o$Foo3 = o == null ? void 0 : o.Foo) === null || _o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo3, _x)[_x].toString(); - (_deep$very$o$Foo = deep == null ? void 0 : (_deep$very$o = deep.very.o) == null ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo, _x)[_x]; - (_deep$very$o$Foo2 = deep == null ? void 0 : (_deep$very$o2 = deep.very.o) == null ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo2, _x)[_x].toString; - (_deep$very$o$Foo3 = deep == null ? void 0 : (_deep$very$o3 = deep.very.o) == null ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo3, _x)[_x].toString(); + (_deep$very$o$Foo = deep == null || (_deep$very$o = deep.very.o) == null ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo, _x)[_x]; + (_deep$very$o$Foo2 = deep == null || (_deep$very$o2 = deep.very.o) == null ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo2, _x)[_x].toString; + (_deep$very$o$Foo3 = deep == null || (_deep$very$o3 = deep.very.o) == null ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_deep$very$o$Foo3, _x)[_x].toString(); (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) === null || _ref === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref, _x)[_x]; (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) === null || _ref2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref2, _x)[_x]; (_self2 = (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref7.self) === null || _self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self2, _x)[_x]; (_self3 = (_ref8 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) == null ? void 0 : _ref8.self) === null || _self3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self3, _x)[_x]; - (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : (_ref9$self = _ref9.self) == null ? void 0 : _ref9$self.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self, _x)[_x]; + (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref9 = _ref9.self) == null ? void 0 : _ref9.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self, _x)[_x]; (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) === null || _ref3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref3, _x)[_x]; (_call = (_ref10 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? void 0 : _ref10.call(_babelHelpers$classPr)) === null || _call === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call, _x)[_x]; (_getSelf = (_ref11 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref11.getSelf()) === null || _getSelf === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf, _x)[_x]; - (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref12.getSelf == null ? void 0 : _ref12.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf2, _x)[_x]; + (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref12.getSelf == null ? void 0 : _ref12.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf2, _x)[_x]; (_self4 = (_ref13 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) == null ? void 0 : _ref13.self) === null || _self4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self4, _x)[_x]; - (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? void 0 : (_ref14$call = _ref14.call(_babelHelpers$classPr2)) == null ? void 0 : _ref14$call.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self, _x)[_x]; - (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : (_ref15$getSelf = _ref15.getSelf()) == null ? void 0 : _ref15$getSelf.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self, _x)[_x]; - (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? void 0 : _ref16.getSelf == null ? void 0 : (_ref16$getSelf = _ref16.getSelf()) == null ? void 0 : _ref16$getSelf.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self2, _x)[_x]; + (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null || (_ref14 = _ref14.call(_babelHelpers$classPr2)) == null ? void 0 : _ref14.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self, _x)[_x]; + (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref15 = _ref15.getSelf()) == null ? void 0 : _ref15.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self, _x)[_x]; + (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref16.getSelf == null || (_ref16 = _ref16.getSelf()) == null ? void 0 : _ref16.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self2, _x)[_x]; (_fn$Foo = fn == null ? void 0 : fn().Foo) === null || _fn$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo, _x)[_x]; (_fn$Foo2 = fn == null ? void 0 : fn().Foo) === null || _fn$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo2, _x)[_x].toString; (_fn$Foo3 = fn == null ? void 0 : fn().Foo) === null || _fn$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo3, _x)[_x].toString(); - (_fnDeep$very$o$Foo = fnDeep == null ? void 0 : (_fnDeep$very$o = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo, _x)[_x]; - (_fnDeep$very$o$Foo2 = fnDeep == null ? void 0 : (_fnDeep$very$o2 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo2, _x)[_x].toString; - (_fnDeep$very$o$Foo3 = fnDeep == null ? void 0 : (_fnDeep$very$o3 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo3, _x)[_x].toString(); + (_fnDeep$very$o$Foo = fnDeep == null || (_fnDeep$very$o = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo, _x)[_x]; + (_fnDeep$very$o$Foo2 = fnDeep == null || (_fnDeep$very$o2 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo2, _x)[_x].toString; + (_fnDeep$very$o$Foo3 = fnDeep == null || (_fnDeep$very$o3 = fnDeep().very.o) == null ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o$Foo3, _x)[_x].toString(); (_ref4 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) === null || _ref4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref4, _x)[_x]; (_ref5 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) === null || _ref5 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref5, _x)[_x]; (_self5 = (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref17.self) === null || _self5 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self5, _x)[_x]; (_self6 = (_ref18 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) == null ? void 0 : _ref18.self) === null || _self6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self6, _x)[_x]; - (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : (_ref19$self = _ref19.self) == null ? void 0 : _ref19$self.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self2, _x)[_x]; + (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref19 = _ref19.self) == null ? void 0 : _ref19.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self$self2, _x)[_x]; (_ref6 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_ref6, _x)[_x]; (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr3 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : _ref20.call(_babelHelpers$classPr3)) === null || _call2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call2, _x)[_x]; (_getSelf3 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref21.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf3, _x)[_x]; - (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf4, _x)[_x]; + (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref22.getSelf == null ? void 0 : _ref22.getSelf()) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf4, _x)[_x]; (_self7 = (_ref23 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) == null ? void 0 : _ref23.self) === null || _self7 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_self7, _x)[_x]; - (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? void 0 : (_ref24$call = _ref24.call(_babelHelpers$classPr4)) == null ? void 0 : _ref24$call.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self2, _x)[_x]; - (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : (_ref25$getSelf = _ref25.getSelf()) == null ? void 0 : _ref25$getSelf.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self3, _x)[_x]; - (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? void 0 : _ref26.getSelf == null ? void 0 : (_ref26$getSelf = _ref26.getSelf()) == null ? void 0 : _ref26$getSelf.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self4, _x)[_x]; + (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null || (_ref24 = _ref24.call(_babelHelpers$classPr4)) == null ? void 0 : _ref24.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_call$self2, _x)[_x]; + (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref25 = _ref25.getSelf()) == null ? void 0 : _ref25.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self3, _x)[_x]; + (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref26.getSelf == null || (_ref26 = _ref26.getSelf()) == null ? void 0 : _ref26.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_getSelf$self4, _x)[_x]; } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/parenthesized-optional-member-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/parenthesized-optional-member-call-with-transform/output.js index b424ead70de2..ab239aea0397 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/parenthesized-optional-member-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private-loose/parenthesized-optional-member-call-with-transform/output.js @@ -5,7 +5,7 @@ class Foo { return Foo; } test() { - var _o$Foo$self$getSelf, _o$Foo$self$getSelf2, _fn$Foo$self$getSelf, _fn$Foo$self$getSelf2, _o$Foo, _o$Foo$self, _fn, _fn$Foo, _fn$Foo$self; + var _o$Foo$self$getSelf, _o$Foo$self$getSelf2, _fn$Foo$self$getSelf, _fn$Foo$self$getSelf2, _o$Foo, _o$Foo$self, _fn, _fn$Foo$self; const o = { Foo: Foo }; @@ -20,8 +20,8 @@ class Foo { (o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _m)[_m].bind(o.Foo))().toString(); ((_o$Foo$self$getSelf = ((_o$Foo = o.Foo) == null ? void 0 : _o$Foo.self.getSelf.bind(_o$Foo.self))()) === null || _o$Foo$self$getSelf === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo$self$getSelf, _m)[_m].bind(_o$Foo$self$getSelf))(); ((_o$Foo$self$getSelf2 = ((_o$Foo$self = o.Foo.self) == null ? void 0 : _o$Foo$self.getSelf.bind(_o$Foo$self))()) === null || _o$Foo$self$getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_o$Foo$self$getSelf2, _m)[_m].bind(_o$Foo$self$getSelf2))(); - ((_fn$Foo$self$getSelf = ((_fn = fn()) == null ? void 0 : (_fn$Foo = _fn.Foo) == null ? void 0 : _fn$Foo.self.getSelf.bind(_fn$Foo.self))()) === null || _fn$Foo$self$getSelf === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo$self$getSelf, _m)[_m].bind(_fn$Foo$self$getSelf))(); - ((_fn$Foo$self$getSelf2 = (fn == null ? void 0 : (_fn$Foo$self = fn().Foo.self) == null ? void 0 : _fn$Foo$self.getSelf.bind(_fn$Foo$self))()) === null || _fn$Foo$self$getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo$self$getSelf2, _m)[_m].bind(_fn$Foo$self$getSelf2))(); + ((_fn$Foo$self$getSelf = ((_fn = fn()) == null || (_fn = _fn.Foo) == null ? void 0 : _fn.self.getSelf.bind(_fn.self))()) === null || _fn$Foo$self$getSelf === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo$self$getSelf, _m)[_m].bind(_fn$Foo$self$getSelf))(); + ((_fn$Foo$self$getSelf2 = (fn == null || (_fn$Foo$self = fn().Foo.self) == null ? void 0 : _fn$Foo$self.getSelf.bind(_fn$Foo$self))()) === null || _fn$Foo$self$getSelf2 === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(_fn$Foo$self$getSelf2, _m)[_m].bind(_fn$Foo$self$getSelf2))(); } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-member-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-member-call-with-transform/output.js index 2a9298ed824a..5065ed79aa7f 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-member-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-member-call-with-transform/output.js @@ -36,7 +36,7 @@ class Foo { (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref6$self = _ref6.self, Foo, _m).call(_ref6$self); (_call = (_ref15 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt5 = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref15 === void 0 ? void 0 : _ref15.call(_babelHelpers$classSt5)) === null || _call === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self = _call.self, Foo, _m).call(_call$self); (_getSelf2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref16 === void 0 ? void 0 : _ref16.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf2$self = _getSelf2.self, Foo, _m).call(_getSelf2$self); - (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref17 === void 0 ? void 0 : (_ref17$getSelf = _ref17.getSelf) === null || _ref17$getSelf === void 0 ? void 0 : _ref17$getSelf.call(_ref17)) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3$self = _getSelf3.self, Foo, _m).call(_getSelf3$self); + (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref17 === void 0 || (_ref17$getSelf = _ref17.getSelf) === null || _ref17$getSelf === void 0 ? void 0 : _ref17$getSelf.call(_ref17)) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3$self = _getSelf3.self, Foo, _m).call(_getSelf3$self); fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo = fn().Foo, Foo, _m).call(_fn$Foo); fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo2 = fn().Foo, Foo, _m).call(_fn$Foo2).toString; fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo3 = fn().Foo, Foo, _m).call(_fn$Foo3).toString(); @@ -55,7 +55,7 @@ class Foo { (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).getSelf()) === null || _ref12 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref12$self = _ref12.self, Foo, _m).call(_ref12$self); (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt10 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref20 === void 0 ? void 0 : _ref20.call(_babelHelpers$classSt10)) === null || _call2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call2$self = _call2.self, Foo, _m).call(_call2$self); (_getSelf5 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref21 === void 0 ? void 0 : _ref21.getSelf()) === null || _getSelf5 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf5$self = _getSelf5.self, Foo, _m).call(_getSelf5$self); - (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _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 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf6$self = _getSelf6.self, Foo, _m).call(_getSelf6$self); + (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref22 === void 0 || (_ref22$getSelf = _ref22.getSelf) === null || _ref22$getSelf === void 0 ? void 0 : _ref22$getSelf.call(_ref22)) === null || _getSelf6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf6$self = _getSelf6.self, Foo, _m).call(_getSelf6$self); } } var _x = { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-property-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-property-with-transform/output.js index 3ccae553a550..08be8b61efcc 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-property-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-before-property-with-transform/output.js @@ -36,7 +36,7 @@ class Foo { (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref6.self, Foo, _x); (_call = (_ref15 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt2 = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref15 === void 0 ? void 0 : _ref15.call(_babelHelpers$classSt2)) === null || _call === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call.self, Foo, _x); (_getSelf2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref16 === void 0 ? void 0 : _ref16.getSelf()) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf2.self, Foo, _x); - (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref17 === void 0 ? void 0 : (_ref17$getSelf = _ref17.getSelf) === null || _ref17$getSelf === void 0 ? void 0 : _ref17$getSelf.call(_ref17)) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3.self, Foo, _x); + (_getSelf3 = (_ref17 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref17 === void 0 || (_ref17$getSelf = _ref17.getSelf) === null || _ref17$getSelf === void 0 ? void 0 : _ref17$getSelf.call(_ref17)) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3.self, Foo, _x); fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _x); fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _x).toString; fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _x).toString(); @@ -55,7 +55,7 @@ class Foo { (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).getSelf()) === null || _ref12 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref12.self, Foo, _x); (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt4 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref20 === void 0 ? void 0 : _ref20.call(_babelHelpers$classSt4)) === null || _call2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call2.self, Foo, _x); (_getSelf5 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref21 === void 0 ? void 0 : _ref21.getSelf()) === null || _getSelf5 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf5.self, Foo, _x); - (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _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 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf6.self, Foo, _x); + (_getSelf6 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref22 === void 0 || (_ref22$getSelf = _ref22.getSelf) === null || _ref22$getSelf === void 0 ? void 0 : _ref22$getSelf.call(_ref22)) === null || _getSelf6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf6.self, Foo, _x); } } var _x = { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-delete-property-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-delete-property-with-transform/output.js index 12a0e11c0583..54b1573cdb0d 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-delete-property-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-delete-property-with-transform/output.js @@ -5,7 +5,7 @@ class Foo { return this; } static test() { - var _deep$very$o, _babelHelpers$classPr, _babelHelpers$classPr2, _fnDeep$very$o, _babelHelpers$classPr3, _babelHelpers$classPr4, _ref, _ref2, _ref3, _ref3$self, _ref4, _ref5, _ref6, _ref7, _ref8, _ref8$call, _ref9, _ref9$getSelf, _ref10, _ref10$getSelf, _ref11, _ref12, _ref13, _ref13$self, _ref14, _ref15, _ref16, _ref17, _ref18, _ref18$call, _ref19, _ref19$getSelf, _ref20, _ref20$getSelf; + var _deep$very$o, _babelHelpers$classPr, _babelHelpers$classPr2, _fnDeep$very$o, _babelHelpers$classPr3, _babelHelpers$classPr4, _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref17, _ref18, _ref19, _ref20; const o = { Foo: Foo }; @@ -24,32 +24,32 @@ class Foo { (_deep$very$o = deep == null ? void 0 : deep.very.o) === null || _deep$very$o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(_deep$very$o.Foo, _self)[_self].unicorn; o === null || o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].unicorn; o === null || o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self.unicorn; - (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : delete _ref.self.unicorn; - (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) == null ? true : delete _ref2.self.unicorn; - (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : (_ref3$self = _ref3.self) == null ? true : delete _ref3$self.self.unicorn; + (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || delete _ref.self.unicorn; + (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].self) == null || delete _ref2.self.unicorn; + (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref3 = _ref3.self) == null || delete _ref3.self.unicorn; o === null || o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf().unicorn; - (_ref4 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? true : delete _ref4.call(_babelHelpers$classPr).unicorn; - (_ref5 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : delete _ref5.getSelf().unicorn; - (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : _ref6.getSelf == null ? true : delete _ref6.getSelf().unicorn; - (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) == null ? true : delete _ref7.self.unicorn; - (_ref8 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null ? true : (_ref8$call = _ref8.call(_babelHelpers$classPr2)) == null ? true : delete _ref8$call.self.unicorn; - (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : (_ref9$getSelf = _ref9.getSelf()) == null ? true : delete _ref9$getSelf.self.unicorn; - (_ref10 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null ? true : _ref10.getSelf == null ? true : (_ref10$getSelf = _ref10.getSelf()) == null ? true : delete _ref10$getSelf.self.unicorn; + (_ref4 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null || delete _ref4.call(_babelHelpers$classPr).unicorn; + (_ref5 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || delete _ref5.getSelf().unicorn; + (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref6.getSelf == null || delete _ref6.getSelf().unicorn; + (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self].getSelf()) == null || delete _ref7.self.unicorn; + (_ref8 = o === null || o === void 0 ? void 0 : (_babelHelpers$classPr2 = babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]).getSelf) == null || (_ref8 = _ref8.call(_babelHelpers$classPr2)) == null || delete _ref8.self.unicorn; + (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || (_ref9 = _ref9.getSelf()) == null || delete _ref9.self.unicorn; + (_ref10 = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o.Foo, _self)[_self]) == null || _ref10.getSelf == null || (_ref10 = _ref10.getSelf()) == null || delete _ref10.self.unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].unicorn; (_fnDeep$very$o = fnDeep == null ? void 0 : fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(_fnDeep$very$o.Foo, _self)[_self].unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self.unicorn; - (_ref11 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : delete _ref11.self.unicorn; - (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) == null ? true : delete _ref12.self.unicorn; - (_ref13 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : (_ref13$self = _ref13.self) == null ? true : delete _ref13$self.self.unicorn; + (_ref11 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || delete _ref11.self.unicorn; + (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].self) == null || delete _ref12.self.unicorn; + (_ref13 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref13 = _ref13.self) == null || delete _ref13.self.unicorn; fn === null || fn === void 0 ? true : delete babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf().unicorn; - (_ref14 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr3 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? true : delete _ref14.call(_babelHelpers$classPr3).unicorn; - (_ref15 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : delete _ref15.getSelf().unicorn; - (_ref16 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : _ref16.getSelf == null ? true : delete _ref16.getSelf().unicorn; - (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) == null ? true : delete _ref17.self.unicorn; - (_ref18 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null ? true : (_ref18$call = _ref18.call(_babelHelpers$classPr4)) == null ? true : delete _ref18$call.self.unicorn; - (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : (_ref19$getSelf = _ref19.getSelf()) == null ? true : delete _ref19$getSelf.self.unicorn; - (_ref20 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null ? true : _ref20.getSelf == null ? true : (_ref20$getSelf = _ref20.getSelf()) == null ? true : delete _ref20$getSelf.self.unicorn; + (_ref14 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr3 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null || delete _ref14.call(_babelHelpers$classPr3).unicorn; + (_ref15 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || delete _ref15.getSelf().unicorn; + (_ref16 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref16.getSelf == null || delete _ref16.getSelf().unicorn; + (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self].getSelf()) == null || delete _ref17.self.unicorn; + (_ref18 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classPr4 = babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]).getSelf) == null || (_ref18 = _ref18.call(_babelHelpers$classPr4)) == null || delete _ref18.self.unicorn; + (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || (_ref19 = _ref19.getSelf()) == null || delete _ref19.self.unicorn; + (_ref20 = fn === null || fn === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(fn().Foo, _self)[_self]) == null || _ref20.getSelf == null || (_ref20 = _ref20.getSelf()) == null || delete _ref20.self.unicorn; } } Object.defineProperty(Foo, _x, { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-in-function-param-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-in-function-param-with-transform/output.js index 7d7f7611fbff..5139545a285a 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-in-function-param-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-in-function-param-with-transform/output.js @@ -23,7 +23,7 @@ class Foo { function g(o, r = (_ref => (_ref = (() => o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf(), Foo, _m))()) === null || _ref === void 0 ? void 0 : _ref())()) { return r; } - function h(fnDeep, r = ((_fnDeep$very$o$Foo, _fnDeep$very$o) => (_fnDeep$very$o$Foo = fnDeep === null || fnDeep === void 0 ? void 0 : (_fnDeep$very$o = fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo, Foo, _m).call(_fnDeep$very$o$Foo))()) { + function h(fnDeep, r = ((_fnDeep$very$o$Foo, _fnDeep$very$o) => (_fnDeep$very$o$Foo = fnDeep === null || fnDeep === void 0 || (_fnDeep$very$o = fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo, Foo, _m).call(_fnDeep$very$o$Foo))()) { return r; } function i(fn, r = ((_getSelf, _getSelf$self, _ref2) => (_getSelf = (_ref2 = (() => fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self))()) === null || _ref2 === void 0 ? void 0 : _ref2.getSelf()) === null || _getSelf === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self = _getSelf.self, Foo, _m).call(_getSelf$self))()) { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-member-optional-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-member-optional-call-with-transform/output.js index 3ee529495247..4bc2c6d0a294 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-member-optional-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-member-optional-call-with-transform/output.js @@ -39,7 +39,7 @@ class Foo { (_ref6 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf()) === null || _ref6 === void 0 ? void 0 : (_babelHelpers$classSt26 = babelHelpers.classStaticPrivateFieldSpecGet(_ref6$self = _ref6.self, Foo, _m)) === null || _babelHelpers$classSt26 === void 0 ? void 0 : _babelHelpers$classSt26.call(_ref6$self); (_call = (_ref18 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt5 = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref18 === void 0 ? void 0 : _ref18.call(_babelHelpers$classSt5)) === null || _call === void 0 ? void 0 : (_babelHelpers$classSt27 = babelHelpers.classStaticPrivateFieldSpecGet(_call$self = _call.self, Foo, _m)) === null || _babelHelpers$classSt27 === void 0 ? void 0 : _babelHelpers$classSt27.call(_call$self); (_getSelf2 = (_ref19 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref19 === void 0 ? void 0 : _ref19.getSelf()) === null || _getSelf2 === void 0 ? void 0 : (_babelHelpers$classSt28 = babelHelpers.classStaticPrivateFieldSpecGet(_getSelf2$self = _getSelf2.self, Foo, _m)) === null || _babelHelpers$classSt28 === void 0 ? void 0 : _babelHelpers$classSt28.call(_getSelf2$self); - (_getSelf3 = (_ref20 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref20 === void 0 ? void 0 : (_ref20$getSelf = _ref20.getSelf) === null || _ref20$getSelf === void 0 ? void 0 : _ref20$getSelf.call(_ref20)) === null || _getSelf3 === void 0 ? void 0 : (_babelHelpers$classSt29 = babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3$self = _getSelf3.self, Foo, _m)) === null || _babelHelpers$classSt29 === void 0 ? void 0 : _babelHelpers$classSt29.call(_getSelf3$self); + (_getSelf3 = (_ref20 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref20 === void 0 || (_ref20$getSelf = _ref20.getSelf) === null || _ref20$getSelf === void 0 ? void 0 : _ref20$getSelf.call(_ref20)) === null || _getSelf3 === void 0 ? void 0 : (_babelHelpers$classSt29 = babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3$self = _getSelf3.self, Foo, _m)) === null || _babelHelpers$classSt29 === void 0 ? void 0 : _babelHelpers$classSt29.call(_getSelf3$self); fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt30 = babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo = fn().Foo, Foo, _m)) === null || _babelHelpers$classSt30 === void 0 ? void 0 : _babelHelpers$classSt30.call(_fn$Foo); fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt31 = babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo2 = fn().Foo, Foo, _m)) === null || _babelHelpers$classSt31 === void 0 ? void 0 : _babelHelpers$classSt31.call(_fn$Foo2).toString; fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt32 = babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo3 = fn().Foo, Foo, _m)) === null || _babelHelpers$classSt32 === void 0 ? void 0 : _babelHelpers$classSt32.call(_fn$Foo3).toString(); @@ -58,7 +58,7 @@ class Foo { (_ref12 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).getSelf()) === null || _ref12 === void 0 ? void 0 : (_babelHelpers$classSt42 = babelHelpers.classStaticPrivateFieldSpecGet(_ref12$self = _ref12.self, Foo, _m)) === null || _babelHelpers$classSt42 === void 0 ? void 0 : _babelHelpers$classSt42.call(_ref12$self); (_call2 = (_ref26 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt10 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref26 === void 0 ? void 0 : _ref26.call(_babelHelpers$classSt10)) === null || _call2 === void 0 ? void 0 : (_babelHelpers$classSt43 = babelHelpers.classStaticPrivateFieldSpecGet(_call2$self = _call2.self, Foo, _m)) === null || _babelHelpers$classSt43 === void 0 ? void 0 : _babelHelpers$classSt43.call(_call2$self); (_getSelf5 = (_ref27 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref27 === void 0 ? void 0 : _ref27.getSelf()) === null || _getSelf5 === void 0 ? void 0 : (_babelHelpers$classSt44 = babelHelpers.classStaticPrivateFieldSpecGet(_getSelf5$self = _getSelf5.self, Foo, _m)) === null || _babelHelpers$classSt44 === void 0 ? void 0 : _babelHelpers$classSt44.call(_getSelf5$self); - (_getSelf6 = (_ref28 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref28 === void 0 ? void 0 : (_ref28$getSelf = _ref28.getSelf) === null || _ref28$getSelf === void 0 ? void 0 : _ref28$getSelf.call(_ref28)) === null || _getSelf6 === void 0 ? void 0 : (_babelHelpers$classSt45 = babelHelpers.classStaticPrivateFieldSpecGet(_getSelf6$self = _getSelf6.self, Foo, _m)) === null || _babelHelpers$classSt45 === void 0 ? void 0 : _babelHelpers$classSt45.call(_getSelf6$self); + (_getSelf6 = (_ref28 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref28 === void 0 || (_ref28$getSelf = _ref28.getSelf) === null || _ref28$getSelf === void 0 ? void 0 : _ref28$getSelf.call(_ref28)) === null || _getSelf6 === void 0 ? void 0 : (_babelHelpers$classSt45 = babelHelpers.classStaticPrivateFieldSpecGet(_getSelf6$self = _getSelf6.self, Foo, _m)) === null || _babelHelpers$classSt45 === void 0 ? void 0 : _babelHelpers$classSt45.call(_getSelf6$self); } } var _x = { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-member-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-member-call-with-transform/output.js index f39063182c01..a00d539903ad 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-member-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-member-call-with-transform/output.js @@ -3,7 +3,7 @@ class Foo { return this; } static test() { - var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classSt, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classSt2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classSt3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classSt4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref9$self, _ref10, _ref11, _ref12, _ref12$getSelf, _ref13, _ref14, _ref14$call, _ref15, _ref15$getSelf, _ref16, _ref16$getSelf, _ref16$getSelf$call, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref19$self, _ref20, _ref21, _ref22, _ref22$getSelf, _ref23, _ref24, _ref24$call, _ref25, _ref25$getSelf, _ref26, _ref26$getSelf, _ref26$getSelf$call; + var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classSt, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classSt2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classSt3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classSt4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref12$getSelf, _ref13, _ref14, _ref15, _ref16, _ref16$getSelf, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref22$getSelf, _ref23, _ref24, _ref25, _ref26, _ref26$getSelf; const o = { Foo: Foo }; @@ -24,41 +24,41 @@ class Foo { (_o$Foo = o === null || o === void 0 ? void 0 : o.Foo) === null || _o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo, Foo, _m).call(_o$Foo); (_o$Foo2 = o === null || o === void 0 ? void 0 : o.Foo) === null || _o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo2, Foo, _m).call(_o$Foo2).toString; (_o$Foo3 = o === null || o === void 0 ? void 0 : o.Foo) === null || _o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo3, Foo, _m).call(_o$Foo3).toString(); - (_deep$very$o$Foo = deep === null || deep === void 0 ? void 0 : (_deep$very$o = deep.very.o) === null || _deep$very$o === void 0 ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo, Foo, _m).call(_deep$very$o$Foo); - (_deep$very$o$Foo2 = deep === null || deep === void 0 ? void 0 : (_deep$very$o2 = deep.very.o) === null || _deep$very$o2 === void 0 ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo2, Foo, _m).call(_deep$very$o$Foo2).toString; - (_deep$very$o$Foo3 = deep === null || deep === void 0 ? void 0 : (_deep$very$o3 = deep.very.o) === null || _deep$very$o3 === void 0 ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo3, Foo, _m).call(_deep$very$o$Foo3).toString(); + (_deep$very$o$Foo = deep === null || deep === void 0 || (_deep$very$o = deep.very.o) === null || _deep$very$o === void 0 ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo, Foo, _m).call(_deep$very$o$Foo); + (_deep$very$o$Foo2 = deep === null || deep === void 0 || (_deep$very$o2 = deep.very.o) === null || _deep$very$o2 === void 0 ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo2, Foo, _m).call(_deep$very$o$Foo2).toString; + (_deep$very$o$Foo3 = deep === null || deep === void 0 || (_deep$very$o3 = deep.very.o) === null || _deep$very$o3 === void 0 ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo3, Foo, _m).call(_deep$very$o$Foo3).toString(); (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref, Foo, _m).call(_ref); (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).self) === null || _ref2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref2, Foo, _m).call(_ref2); (_self2 = (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref7 === void 0 ? void 0 : _ref7.self) === null || _self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self2, Foo, _m).call(_self2); (_self3 = (_ref8 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).self) === null || _ref8 === void 0 ? void 0 : _ref8.self) === null || _self3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self3, Foo, _m).call(_self3); - (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref9 === void 0 ? void 0 : (_ref9$self = _ref9.self) === null || _ref9$self === void 0 ? void 0 : _ref9$self.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self, Foo, _m).call(_self$self); + (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref9 === void 0 || (_ref9 = _ref9.self) === null || _ref9 === void 0 ? void 0 : _ref9.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self, Foo, _m).call(_self$self); (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf()) === null || _ref3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref3, Foo, _m).call(_ref3); (_call = (_ref10 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref10 === void 0 ? void 0 : _ref10.call(_babelHelpers$classSt)) === null || _call === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call, Foo, _m).call(_call); (_getSelf = (_ref11 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref11 === void 0 ? void 0 : _ref11.getSelf()) === null || _getSelf === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf, Foo, _m).call(_getSelf); - (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref12 === void 0 ? void 0 : (_ref12$getSelf = _ref12.getSelf) === null || _ref12$getSelf === void 0 ? void 0 : _ref12$getSelf.call(_ref12)) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf2, Foo, _m).call(_getSelf2); + (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref12 === void 0 || (_ref12$getSelf = _ref12.getSelf) === null || _ref12$getSelf === void 0 ? void 0 : _ref12$getSelf.call(_ref12)) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf2, Foo, _m).call(_getSelf2); (_self4 = (_ref13 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf()) === null || _ref13 === void 0 ? void 0 : _ref13.self) === null || _self4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self4, Foo, _m).call(_self4); - (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt2 = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref14 === void 0 ? void 0 : (_ref14$call = _ref14.call(_babelHelpers$classSt2)) === null || _ref14$call === void 0 ? void 0 : _ref14$call.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self, Foo, _m).call(_call$self); - (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref15 === void 0 ? void 0 : (_ref15$getSelf = _ref15.getSelf()) === null || _ref15$getSelf === void 0 ? void 0 : _ref15$getSelf.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self, Foo, _m).call(_getSelf$self); - (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref16 === void 0 ? void 0 : (_ref16$getSelf = _ref16.getSelf) === null || _ref16$getSelf === void 0 ? void 0 : (_ref16$getSelf$call = _ref16$getSelf.call(_ref16)) === null || _ref16$getSelf$call === void 0 ? void 0 : _ref16$getSelf$call.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self2, Foo, _m).call(_getSelf$self2); + (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt2 = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref14 === void 0 || (_ref14 = _ref14.call(_babelHelpers$classSt2)) === null || _ref14 === void 0 ? void 0 : _ref14.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self, Foo, _m).call(_call$self); + (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref15 === void 0 || (_ref15 = _ref15.getSelf()) === null || _ref15 === void 0 ? void 0 : _ref15.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self, Foo, _m).call(_getSelf$self); + (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref16 === void 0 || (_ref16$getSelf = _ref16.getSelf) === null || _ref16$getSelf === void 0 || (_ref16$getSelf = _ref16$getSelf.call(_ref16)) === null || _ref16$getSelf === void 0 ? void 0 : _ref16$getSelf.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self2, Foo, _m).call(_getSelf$self2); (_fn$Foo = fn === null || fn === void 0 ? void 0 : fn().Foo) === null || _fn$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo, Foo, _m).call(_fn$Foo); (_fn$Foo2 = fn === null || fn === void 0 ? void 0 : fn().Foo) === null || _fn$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo2, Foo, _m).call(_fn$Foo2).toString; (_fn$Foo3 = fn === null || fn === void 0 ? void 0 : fn().Foo) === null || _fn$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo3, Foo, _m).call(_fn$Foo3).toString(); - (_fnDeep$very$o$Foo = fnDeep === null || fnDeep === void 0 ? void 0 : (_fnDeep$very$o = fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo, Foo, _m).call(_fnDeep$very$o$Foo); - (_fnDeep$very$o$Foo2 = fnDeep === null || fnDeep === void 0 ? void 0 : (_fnDeep$very$o2 = fnDeep().very.o) === null || _fnDeep$very$o2 === void 0 ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo2, Foo, _m).call(_fnDeep$very$o$Foo2).toString; - (_fnDeep$very$o$Foo3 = fnDeep === null || fnDeep === void 0 ? void 0 : (_fnDeep$very$o3 = fnDeep().very.o) === null || _fnDeep$very$o3 === void 0 ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo3, Foo, _m).call(_fnDeep$very$o$Foo3).toString(); + (_fnDeep$very$o$Foo = fnDeep === null || fnDeep === void 0 || (_fnDeep$very$o = fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo, Foo, _m).call(_fnDeep$very$o$Foo); + (_fnDeep$very$o$Foo2 = fnDeep === null || fnDeep === void 0 || (_fnDeep$very$o2 = fnDeep().very.o) === null || _fnDeep$very$o2 === void 0 ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo2, Foo, _m).call(_fnDeep$very$o$Foo2).toString; + (_fnDeep$very$o$Foo3 = fnDeep === null || fnDeep === void 0 || (_fnDeep$very$o3 = fnDeep().very.o) === null || _fnDeep$very$o3 === void 0 ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo3, Foo, _m).call(_fnDeep$very$o$Foo3).toString(); (_ref4 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref4, Foo, _m).call(_ref4); (_ref5 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).self) === null || _ref5 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref5, Foo, _m).call(_ref5); (_self5 = (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref17 === void 0 ? void 0 : _ref17.self) === null || _self5 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self5, Foo, _m).call(_self5); (_self6 = (_ref18 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).self) === null || _ref18 === void 0 ? void 0 : _ref18.self) === null || _self6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self6, Foo, _m).call(_self6); - (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref19 === void 0 ? void 0 : (_ref19$self = _ref19.self) === null || _ref19$self === void 0 ? void 0 : _ref19$self.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self2, Foo, _m).call(_self$self2); + (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref19 === void 0 || (_ref19 = _ref19.self) === null || _ref19 === void 0 ? void 0 : _ref19.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self2, Foo, _m).call(_self$self2); (_ref6 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref6, Foo, _m).call(_ref6); (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt3 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref20 === void 0 ? void 0 : _ref20.call(_babelHelpers$classSt3)) === null || _call2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call2, Foo, _m).call(_call2); (_getSelf3 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref21 === void 0 ? void 0 : _ref21.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3, Foo, _m).call(_getSelf3); - (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref22 === void 0 ? void 0 : (_ref22$getSelf = _ref22.getSelf) === null || _ref22$getSelf === void 0 ? void 0 : _ref22$getSelf.call(_ref22)) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf4, Foo, _m).call(_getSelf4); + (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref22 === void 0 || (_ref22$getSelf = _ref22.getSelf) === null || _ref22$getSelf === void 0 ? void 0 : _ref22$getSelf.call(_ref22)) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf4, Foo, _m).call(_getSelf4); (_self7 = (_ref23 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).getSelf()) === null || _ref23 === void 0 ? void 0 : _ref23.self) === null || _self7 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self7, Foo, _m).call(_self7); - (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt4 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref24 === void 0 ? void 0 : (_ref24$call = _ref24.call(_babelHelpers$classSt4)) === null || _ref24$call === void 0 ? void 0 : _ref24$call.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self2, Foo, _m).call(_call$self2); - (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref25 === void 0 ? void 0 : (_ref25$getSelf = _ref25.getSelf()) === null || _ref25$getSelf === void 0 ? void 0 : _ref25$getSelf.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self3, Foo, _m).call(_getSelf$self3); - (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref26 === void 0 ? void 0 : (_ref26$getSelf = _ref26.getSelf) === null || _ref26$getSelf === void 0 ? void 0 : (_ref26$getSelf$call = _ref26$getSelf.call(_ref26)) === null || _ref26$getSelf$call === void 0 ? void 0 : _ref26$getSelf$call.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self4, Foo, _m).call(_getSelf$self4); + (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt4 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref24 === void 0 || (_ref24 = _ref24.call(_babelHelpers$classSt4)) === null || _ref24 === void 0 ? void 0 : _ref24.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self2, Foo, _m).call(_call$self2); + (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref25 === void 0 || (_ref25 = _ref25.getSelf()) === null || _ref25 === void 0 ? void 0 : _ref25.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self3, Foo, _m).call(_getSelf$self3); + (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref26 === void 0 || (_ref26$getSelf = _ref26.getSelf) === null || _ref26$getSelf === void 0 || (_ref26$getSelf = _ref26$getSelf.call(_ref26)) === null || _ref26$getSelf === void 0 ? void 0 : _ref26$getSelf.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self4, Foo, _m).call(_getSelf$self4); } } var _x = { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-property-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-property-with-transform/output.js index a3206d001afe..56e7cf03db79 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-property-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/optional-chain-optional-property-with-transform/output.js @@ -3,7 +3,7 @@ class Foo { return this; } static test() { - var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classSt, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classSt2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classSt3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classSt4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref9$self, _ref10, _ref11, _ref12, _ref12$getSelf, _ref13, _ref14, _ref14$call, _ref15, _ref15$getSelf, _ref16, _ref16$getSelf, _ref16$getSelf$call, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref19$self, _ref20, _ref21, _ref22, _ref22$getSelf, _ref23, _ref24, _ref24$call, _ref25, _ref25$getSelf, _ref26, _ref26$getSelf, _ref26$getSelf$call; + var _o$Foo, _o$Foo2, _o$Foo3, _deep$very$o$Foo, _deep$very$o$Foo2, _deep$very$o$Foo3, _ref, _ref2, _self2, _self3, _self$self, _ref3, _babelHelpers$classSt, _call, _getSelf, _getSelf2, _self4, _babelHelpers$classSt2, _call$self, _getSelf$self, _getSelf$self2, _fn$Foo, _fn$Foo2, _fn$Foo3, _fnDeep$very$o$Foo, _fnDeep$very$o$Foo2, _fnDeep$very$o$Foo3, _ref4, _ref5, _self5, _self6, _self$self2, _ref6, _babelHelpers$classSt3, _call2, _getSelf3, _getSelf4, _self7, _babelHelpers$classSt4, _call$self2, _getSelf$self3, _getSelf$self4, _deep$very$o, _deep$very$o2, _deep$very$o3, _ref7, _ref8, _ref9, _ref10, _ref11, _ref12, _ref12$getSelf, _ref13, _ref14, _ref15, _ref16, _ref16$getSelf, _fnDeep$very$o, _fnDeep$very$o2, _fnDeep$very$o3, _ref17, _ref18, _ref19, _ref20, _ref21, _ref22, _ref22$getSelf, _ref23, _ref24, _ref25, _ref26, _ref26$getSelf; const o = { Foo: Foo }; @@ -24,41 +24,41 @@ class Foo { (_o$Foo = o === null || o === void 0 ? void 0 : o.Foo) === null || _o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo, Foo, _x); (_o$Foo2 = o === null || o === void 0 ? void 0 : o.Foo) === null || _o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo2, Foo, _x).toString; (_o$Foo3 = o === null || o === void 0 ? void 0 : o.Foo) === null || _o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo3, Foo, _x).toString(); - (_deep$very$o$Foo = deep === null || deep === void 0 ? void 0 : (_deep$very$o = deep.very.o) === null || _deep$very$o === void 0 ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo, Foo, _x); - (_deep$very$o$Foo2 = deep === null || deep === void 0 ? void 0 : (_deep$very$o2 = deep.very.o) === null || _deep$very$o2 === void 0 ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo2, Foo, _x).toString; - (_deep$very$o$Foo3 = deep === null || deep === void 0 ? void 0 : (_deep$very$o3 = deep.very.o) === null || _deep$very$o3 === void 0 ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo3, Foo, _x).toString(); + (_deep$very$o$Foo = deep === null || deep === void 0 || (_deep$very$o = deep.very.o) === null || _deep$very$o === void 0 ? void 0 : _deep$very$o.Foo) === null || _deep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo, Foo, _x); + (_deep$very$o$Foo2 = deep === null || deep === void 0 || (_deep$very$o2 = deep.very.o) === null || _deep$very$o2 === void 0 ? void 0 : _deep$very$o2.Foo) === null || _deep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo2, Foo, _x).toString; + (_deep$very$o$Foo3 = deep === null || deep === void 0 || (_deep$very$o3 = deep.very.o) === null || _deep$very$o3 === void 0 ? void 0 : _deep$very$o3.Foo) === null || _deep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_deep$very$o$Foo3, Foo, _x).toString(); (_ref = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref, Foo, _x); (_ref2 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).self) === null || _ref2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref2, Foo, _x); (_self2 = (_ref7 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref7 === void 0 ? void 0 : _ref7.self) === null || _self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self2, Foo, _x); (_self3 = (_ref8 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).self) === null || _ref8 === void 0 ? void 0 : _ref8.self) === null || _self3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self3, Foo, _x); - (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref9 === void 0 ? void 0 : (_ref9$self = _ref9.self) === null || _ref9$self === void 0 ? void 0 : _ref9$self.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self, Foo, _x); + (_self$self = (_ref9 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref9 === void 0 || (_ref9 = _ref9.self) === null || _ref9 === void 0 ? void 0 : _ref9.self) === null || _self$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self, Foo, _x); (_ref3 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf()) === null || _ref3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref3, Foo, _x); (_call = (_ref10 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref10 === void 0 ? void 0 : _ref10.call(_babelHelpers$classSt)) === null || _call === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call, Foo, _x); (_getSelf = (_ref11 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref11 === void 0 ? void 0 : _ref11.getSelf()) === null || _getSelf === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf, Foo, _x); - (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref12 === void 0 ? void 0 : (_ref12$getSelf = _ref12.getSelf) === null || _ref12$getSelf === void 0 ? void 0 : _ref12$getSelf.call(_ref12)) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf2, Foo, _x); + (_getSelf2 = (_ref12 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref12 === void 0 || (_ref12$getSelf = _ref12.getSelf) === null || _ref12$getSelf === void 0 ? void 0 : _ref12$getSelf.call(_ref12)) === null || _getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf2, Foo, _x); (_self4 = (_ref13 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self).getSelf()) === null || _ref13 === void 0 ? void 0 : _ref13.self) === null || _self4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self4, Foo, _x); - (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt2 = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref14 === void 0 ? void 0 : (_ref14$call = _ref14.call(_babelHelpers$classSt2)) === null || _ref14$call === void 0 ? void 0 : _ref14$call.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self, Foo, _x); - (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref15 === void 0 ? void 0 : (_ref15$getSelf = _ref15.getSelf()) === null || _ref15$getSelf === void 0 ? void 0 : _ref15$getSelf.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self, Foo, _x); - (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref16 === void 0 ? void 0 : (_ref16$getSelf = _ref16.getSelf) === null || _ref16$getSelf === void 0 ? void 0 : (_ref16$getSelf$call = _ref16$getSelf.call(_ref16)) === null || _ref16$getSelf$call === void 0 ? void 0 : _ref16$getSelf$call.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self2, Foo, _x); + (_call$self = (_ref14 = o === null || o === void 0 ? void 0 : (_babelHelpers$classSt2 = babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)).getSelf) === null || _ref14 === void 0 || (_ref14 = _ref14.call(_babelHelpers$classSt2)) === null || _ref14 === void 0 ? void 0 : _ref14.self) === null || _call$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self, Foo, _x); + (_getSelf$self = (_ref15 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref15 === void 0 || (_ref15 = _ref15.getSelf()) === null || _ref15 === void 0 ? void 0 : _ref15.self) === null || _getSelf$self === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self, Foo, _x); + (_getSelf$self2 = (_ref16 = o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(o.Foo, Foo, _self)) === null || _ref16 === void 0 || (_ref16$getSelf = _ref16.getSelf) === null || _ref16$getSelf === void 0 || (_ref16$getSelf = _ref16$getSelf.call(_ref16)) === null || _ref16$getSelf === void 0 ? void 0 : _ref16$getSelf.self) === null || _getSelf$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self2, Foo, _x); (_fn$Foo = fn === null || fn === void 0 ? void 0 : fn().Foo) === null || _fn$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo, Foo, _x); (_fn$Foo2 = fn === null || fn === void 0 ? void 0 : fn().Foo) === null || _fn$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo2, Foo, _x).toString; (_fn$Foo3 = fn === null || fn === void 0 ? void 0 : fn().Foo) === null || _fn$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo3, Foo, _x).toString(); - (_fnDeep$very$o$Foo = fnDeep === null || fnDeep === void 0 ? void 0 : (_fnDeep$very$o = fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo, Foo, _x); - (_fnDeep$very$o$Foo2 = fnDeep === null || fnDeep === void 0 ? void 0 : (_fnDeep$very$o2 = fnDeep().very.o) === null || _fnDeep$very$o2 === void 0 ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo2, Foo, _x).toString; - (_fnDeep$very$o$Foo3 = fnDeep === null || fnDeep === void 0 ? void 0 : (_fnDeep$very$o3 = fnDeep().very.o) === null || _fnDeep$very$o3 === void 0 ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo3, Foo, _x).toString(); + (_fnDeep$very$o$Foo = fnDeep === null || fnDeep === void 0 || (_fnDeep$very$o = fnDeep().very.o) === null || _fnDeep$very$o === void 0 ? void 0 : _fnDeep$very$o.Foo) === null || _fnDeep$very$o$Foo === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo, Foo, _x); + (_fnDeep$very$o$Foo2 = fnDeep === null || fnDeep === void 0 || (_fnDeep$very$o2 = fnDeep().very.o) === null || _fnDeep$very$o2 === void 0 ? void 0 : _fnDeep$very$o2.Foo) === null || _fnDeep$very$o$Foo2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo2, Foo, _x).toString; + (_fnDeep$very$o$Foo3 = fnDeep === null || fnDeep === void 0 || (_fnDeep$very$o3 = fnDeep().very.o) === null || _fnDeep$very$o3 === void 0 ? void 0 : _fnDeep$very$o3.Foo) === null || _fnDeep$very$o$Foo3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fnDeep$very$o$Foo3, Foo, _x).toString(); (_ref4 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref4, Foo, _x); (_ref5 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).self) === null || _ref5 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref5, Foo, _x); (_self5 = (_ref17 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref17 === void 0 ? void 0 : _ref17.self) === null || _self5 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self5, Foo, _x); (_self6 = (_ref18 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).self) === null || _ref18 === void 0 ? void 0 : _ref18.self) === null || _self6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self6, Foo, _x); - (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref19 === void 0 ? void 0 : (_ref19$self = _ref19.self) === null || _ref19$self === void 0 ? void 0 : _ref19$self.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self2, Foo, _x); + (_self$self2 = (_ref19 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref19 === void 0 || (_ref19 = _ref19.self) === null || _ref19 === void 0 ? void 0 : _ref19.self) === null || _self$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self$self2, Foo, _x); (_ref6 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).getSelf()) === null || _ref6 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_ref6, Foo, _x); (_call2 = (_ref20 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt3 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref20 === void 0 ? void 0 : _ref20.call(_babelHelpers$classSt3)) === null || _call2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call2, Foo, _x); (_getSelf3 = (_ref21 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref21 === void 0 ? void 0 : _ref21.getSelf()) === null || _getSelf3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf3, Foo, _x); - (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref22 === void 0 ? void 0 : (_ref22$getSelf = _ref22.getSelf) === null || _ref22$getSelf === void 0 ? void 0 : _ref22$getSelf.call(_ref22)) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf4, Foo, _x); + (_getSelf4 = (_ref22 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref22 === void 0 || (_ref22$getSelf = _ref22.getSelf) === null || _ref22$getSelf === void 0 ? void 0 : _ref22$getSelf.call(_ref22)) === null || _getSelf4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf4, Foo, _x); (_self7 = (_ref23 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self).getSelf()) === null || _ref23 === void 0 ? void 0 : _ref23.self) === null || _self7 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_self7, Foo, _x); - (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt4 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref24 === void 0 ? void 0 : (_ref24$call = _ref24.call(_babelHelpers$classSt4)) === null || _ref24$call === void 0 ? void 0 : _ref24$call.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self2, Foo, _x); - (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref25 === void 0 ? void 0 : (_ref25$getSelf = _ref25.getSelf()) === null || _ref25$getSelf === void 0 ? void 0 : _ref25$getSelf.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self3, Foo, _x); - (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref26 === void 0 ? void 0 : (_ref26$getSelf = _ref26.getSelf) === null || _ref26$getSelf === void 0 ? void 0 : (_ref26$getSelf$call = _ref26$getSelf.call(_ref26)) === null || _ref26$getSelf$call === void 0 ? void 0 : _ref26$getSelf$call.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self4, Foo, _x); + (_call$self2 = (_ref24 = fn === null || fn === void 0 ? void 0 : (_babelHelpers$classSt4 = babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)).getSelf) === null || _ref24 === void 0 || (_ref24 = _ref24.call(_babelHelpers$classSt4)) === null || _ref24 === void 0 ? void 0 : _ref24.self) === null || _call$self2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_call$self2, Foo, _x); + (_getSelf$self3 = (_ref25 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref25 === void 0 || (_ref25 = _ref25.getSelf()) === null || _ref25 === void 0 ? void 0 : _ref25.self) === null || _getSelf$self3 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self3, Foo, _x); + (_getSelf$self4 = (_ref26 = fn === null || fn === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(fn().Foo, Foo, _self)) === null || _ref26 === void 0 || (_ref26$getSelf = _ref26.getSelf) === null || _ref26$getSelf === void 0 || (_ref26$getSelf = _ref26$getSelf.call(_ref26)) === null || _ref26$getSelf === void 0 ? void 0 : _ref26$getSelf.self) === null || _getSelf$self4 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_getSelf$self4, Foo, _x); } } var _x = { diff --git a/packages/babel-plugin-transform-class-properties/test/fixtures/private/parenthesized-optional-member-call-with-transform/output.js b/packages/babel-plugin-transform-class-properties/test/fixtures/private/parenthesized-optional-member-call-with-transform/output.js index 5b3664fd6ffd..5f36d568fbfa 100644 --- a/packages/babel-plugin-transform-class-properties/test/fixtures/private/parenthesized-optional-member-call-with-transform/output.js +++ b/packages/babel-plugin-transform-class-properties/test/fixtures/private/parenthesized-optional-member-call-with-transform/output.js @@ -3,7 +3,7 @@ class Foo { return Foo; } test() { - var _o$Foo, _o$Foo2, _o$Foo3, _o$Foo$self$getSelf, _o$Foo$self$getSelf2, _fn$Foo$self$getSelf, _fn$Foo$self$getSelf2, _o$Foo4, _o$Foo4$self, _o$Foo$self, _fn, _fn$Foo, _fn$Foo$self, _fn$Foo$self2; + var _o$Foo, _o$Foo2, _o$Foo3, _o$Foo$self$getSelf, _o$Foo$self$getSelf2, _fn$Foo$self$getSelf, _fn$Foo$self$getSelf2, _o$Foo4, _o$Foo4$self, _o$Foo$self, _fn, _fn$self, _fn$Foo$self; const o = { Foo: Foo }; @@ -18,8 +18,8 @@ class Foo { (o === null || o === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo3 = o.Foo, Foo, _m).bind(_o$Foo3))().toString(); ((_o$Foo$self$getSelf = ((_o$Foo4 = o.Foo) === null || _o$Foo4 === void 0 ? void 0 : (_o$Foo4$self = _o$Foo4.self).getSelf.bind(_o$Foo4$self))()) === null || _o$Foo$self$getSelf === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo$self$getSelf, Foo, _m).bind(_o$Foo$self$getSelf))(); ((_o$Foo$self$getSelf2 = ((_o$Foo$self = o.Foo.self) === null || _o$Foo$self === void 0 ? void 0 : _o$Foo$self.getSelf.bind(_o$Foo$self))()) === null || _o$Foo$self$getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_o$Foo$self$getSelf2, Foo, _m).bind(_o$Foo$self$getSelf2))(); - ((_fn$Foo$self$getSelf = ((_fn = fn()) === null || _fn === void 0 ? void 0 : (_fn$Foo = _fn.Foo) === null || _fn$Foo === void 0 ? void 0 : (_fn$Foo$self = _fn$Foo.self).getSelf.bind(_fn$Foo$self))()) === null || _fn$Foo$self$getSelf === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo$self$getSelf, Foo, _m).bind(_fn$Foo$self$getSelf))(); - ((_fn$Foo$self$getSelf2 = (fn === null || fn === void 0 ? void 0 : (_fn$Foo$self2 = fn().Foo.self) === null || _fn$Foo$self2 === void 0 ? void 0 : _fn$Foo$self2.getSelf.bind(_fn$Foo$self2))()) === null || _fn$Foo$self$getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo$self$getSelf2, Foo, _m).bind(_fn$Foo$self$getSelf2))(); + ((_fn$Foo$self$getSelf = ((_fn = fn()) === null || _fn === void 0 || (_fn = _fn.Foo) === null || _fn === void 0 ? void 0 : (_fn$self = _fn.self).getSelf.bind(_fn$self))()) === null || _fn$Foo$self$getSelf === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo$self$getSelf, Foo, _m).bind(_fn$Foo$self$getSelf))(); + ((_fn$Foo$self$getSelf2 = (fn === null || fn === void 0 || (_fn$Foo$self = fn().Foo.self) === null || _fn$Foo$self === void 0 ? void 0 : _fn$Foo$self.getSelf.bind(_fn$Foo$self))()) === null || _fn$Foo$self$getSelf2 === void 0 ? void 0 : babelHelpers.classStaticPrivateFieldSpecGet(_fn$Foo$self$getSelf2, Foo, _m).bind(_fn$Foo$self$getSelf2))(); } } var _x = { diff --git a/packages/babel-plugin-transform-optional-chaining/src/transform.ts b/packages/babel-plugin-transform-optional-chaining/src/transform.ts index 042ee0eebdb0..d5f05ace117f 100644 --- a/packages/babel-plugin-transform-optional-chaining/src/transform.ts +++ b/packages/babel-plugin-transform-optional-chaining/src/transform.ts @@ -6,8 +6,6 @@ import { } from "@babel/helper-skip-transparent-expression-wrappers"; import { willPathCastToBoolean, findOutermostTransparentParent } from "./util"; -const { ast } = template.expression; - function isSimpleMemberExpression( expression: t.Expression | t.Super, ): expression is t.Identifier | t.Super | t.MemberExpression { @@ -50,6 +48,15 @@ function needsMemoize( } } +const NULLISH_CHECK = template.expression( + `%%check%% === null || %%ref%% === void 0`, +); +const NULLISH_CHECK_NO_DDA = template.expression(`%%check%% == null`); +const NULLISH_CHECK_NEG = template.expression( + `%%check%% !== null && %%ref%% !== void 0`, +); +const NULLISH_CHECK_NO_DDA_NEG = template.expression(`%%check%% != null`); + interface OptionalChainAssumptions { pureGetters: boolean; noDocumentAll: boolean; @@ -59,9 +66,8 @@ export function transformOptionalChain( path: NodePath, { pureGetters, noDocumentAll }: OptionalChainAssumptions, replacementPath: NodePath, - ifNullish: () => t.Expression, + ifNullish: t.Expression, wrapLast?: (value: t.Expression) => t.Expression, - willReplacementCastToBoolean: boolean = false, ) { const { scope } = path; @@ -100,6 +106,16 @@ export function transformOptionalChain( } } + if (optionals.length === 0) { + // Malformed AST: there was an OptionalMemberExpression node + // with no actual optional elements. + return; + } + + const checks = []; + + let tmpVar; + for (let i = optionals.length - 1; i >= 0; i--) { const node = optionals[i] as unknown as | t.MemberExpression @@ -124,23 +140,27 @@ export function transformOptionalChain( // we can avoid a needless memoize. We only do this if the callee is a simple member // expression, to avoid multiple calls to nested call expressions. check = ref = node.callee; + } else if (scope.isStatic(chain)) { + check = ref = chainWithTypes; } else { - ref = scope.maybeGenerateMemoised(chain); - if (ref) { - check = t.assignmentExpression( - "=", - t.cloneNode(ref), - // Here `chainWithTypes` MUST NOT be cloned because it could be - // updated when generating the memoised context of a call - // expression. It must be an Expression when `ref` is an identifier - // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion - chainWithTypes as t.Expression, - ); - - isCall ? (node.callee = ref) : (node.object = ref); - } else { - check = ref = chainWithTypes; + // We cannot re-use the tmpVar for calls, because we need to + // store both the method and the receiver. + if (!tmpVar || isCall) { + tmpVar = scope.generateUidIdentifierBasedOnNode(chain); + scope.push({ id: t.cloneNode(tmpVar) }); } + ref = tmpVar; + check = t.assignmentExpression( + "=", + t.cloneNode(tmpVar), + // Here `chainWithTypes` MUST NOT be cloned because it could be + // updated when generating the memoised context of a call + // expression. It must be an Expression when `ref` is an identifier + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion + chainWithTypes as t.Expression, + ); + + isCall ? (node.callee = ref) : (node.object = ref); } // Ensure call expressions have the proper `this` @@ -173,44 +193,34 @@ export function transformOptionalChain( } } - const replacement = replacementPath.node; + const data = { check: t.cloneNode(check), ref: t.cloneNode(ref) }; + // We make `ref` non-enumerable, so that @babel/template doesn't throw + // in the noDocumentAll template if it's not used. + Object.defineProperty(data, "ref", { enumerable: false }); + checks.push(data); + } + + let result = replacementPath.node; + if (wrapLast) result = wrapLast(result); - if (willReplacementCastToBoolean) { - const nonNullishCheck = noDocumentAll - ? ast`${t.cloneNode(check)} != null` - : ast` - ${t.cloneNode(check)} !== null && ${t.cloneNode(ref)} !== void 0`; + const ifNullishBoolean = t.isBooleanLiteral(ifNullish); + const ifNullishFalse = ifNullishBoolean && ifNullish.value === false; - // `if (a?.b) {}` transformed to `if (a != null && a.b) {}` - // we don't need to return `void 0` because the returned value will - // eventually cast to boolean. - replacementPath.replaceWith( - t.logicalExpression( - "&&", - nonNullishCheck, - i === 0 && wrapLast ? wrapLast(replacement) : replacement, - ), - ); - replacementPath = skipTransparentExprWrappers( - replacementPath.get("right"), - ); - } else { - const nullishCheck = noDocumentAll - ? ast`${t.cloneNode(check)} == null` - : ast` - ${t.cloneNode(check)} === null || ${t.cloneNode(ref)} === void 0`; - replacementPath.replaceWith( - t.conditionalExpression( - nullishCheck, - ifNullish(), - i === 0 && wrapLast ? wrapLast(replacement) : replacement, - ), - ); - replacementPath = skipTransparentExprWrappers( - replacementPath.get("alternate"), - ); - } - } + // prettier-ignore + const tpl = ifNullishFalse + ? (noDocumentAll ? NULLISH_CHECK_NO_DDA_NEG : NULLISH_CHECK_NEG) + : (noDocumentAll ? NULLISH_CHECK_NO_DDA : NULLISH_CHECK); + const logicalOp = ifNullishFalse ? "&&" : "||"; + + const check = checks + .map(tpl) + .reduce((expr, check) => t.logicalExpression(logicalOp, expr, check)); + + replacementPath.replaceWith( + ifNullishBoolean + ? t.logicalExpression(logicalOp, check, result) + : t.conditionalExpression(check, ifNullish, result), + ); } export function transform( @@ -223,10 +233,12 @@ export function transform( // or the path itself const maybeWrapped = findOutermostTransparentParent(path); const { parentPath } = maybeWrapped; - const willReplacementCastToBoolean = willPathCastToBoolean(maybeWrapped); if (parentPath.isUnaryExpression({ operator: "delete" })) { - transformOptionalChain(path, assumptions, parentPath, () => + transformOptionalChain( + path, + assumptions, + parentPath, t.booleanLiteral(true), ); } else { @@ -266,9 +278,10 @@ export function transform( path, assumptions, path, - () => scope.buildUndefinedNode(), + willPathCastToBoolean(maybeWrapped) + ? t.booleanLiteral(false) + : scope.buildUndefinedNode(), wrapLast, - willReplacementCastToBoolean, ); } } diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/assignment/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/assignment/output.js index fe5d5d7d2871..cc0c19934070 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/assignment/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/assignment/output.js @@ -11,7 +11,7 @@ const obj = { } }; const a = obj == null ? void 0 : obj.a; -const b = obj == null ? void 0 : (_obj$a = obj.a) == null ? void 0 : _obj$a.b; -const bad = obj == null ? void 0 : (_obj$b = obj.b) == null ? void 0 : _obj$b.b; +const b = obj == null || (_obj$a = obj.a) == null ? void 0 : _obj$a.b; +const bad = obj == null || (_obj$b = obj.b) == null ? void 0 : _obj$b.b; let val; -val = obj == null ? void 0 : (_obj$a2 = obj.a) == null ? void 0 : _obj$a2.b; +val = obj == null || (_obj$a2 = obj.a) == null ? void 0 : _obj$a2.b; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/cast-to-boolean/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/cast-to-boolean/output.js index 635606664ba5..658de851ca70 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/cast-to-boolean/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/cast-to-boolean/output.js @@ -30,36 +30,36 @@ class C { return !!(o != null && (_o$a$b3 = o.a.b) != null && _o$a$b3.c.d); } static testIfDeep(o) { - var _o$obj, _o$obj$a$b; - if ((_o$obj = o.obj) != null && (_o$obj$a$b = _o$obj.a.b) != null && _o$obj$a$b.c.d) { + var _o$obj; + if ((_o$obj = o.obj) != null && (_o$obj = _o$obj.a.b) != null && _o$obj.c.d) { return true; } return false; } static testConditionalDeep(o) { - var _o$obj2, _o$obj2$a$b; - return (_o$obj2 = o.obj) != null && (_o$obj2$a$b = _o$obj2.a.b) != null && _o$obj2$a$b.c.d ? true : false; + var _o$obj2; + return (_o$obj2 = o.obj) != null && (_o$obj2 = _o$obj2.a.b) != null && _o$obj2.c.d ? true : false; } static testLoopDeep(o) { while ((_o$obj3 = o.obj) != null && _o$obj3.a.b.c.d) { var _o$obj3; - for (; (_o$obj4 = o.obj) != null && (_o$obj4$a$b$c = _o$obj4.a.b.c) != null && _o$obj4$a$b$c.d;) { - var _o$obj4, _o$obj4$a$b$c; + for (; (_o$obj4 = o.obj) != null && (_o$obj4 = _o$obj4.a.b.c) != null && _o$obj4.d;) { + var _o$obj4; let i = 0; do { - var _o$obj5, _o$obj5$a$b; + var _o$obj5; i++; if (i === 2) { return true; } - } while ((_o$obj5 = o.obj) != null && (_o$obj5$a$b = _o$obj5.a.b) != null && _o$obj5$a$b.c.d); + } while ((_o$obj5 = o.obj) != null && (_o$obj5 = _o$obj5.a.b) != null && _o$obj5.c.d); } } return false; } static testNegateDeep(o) { - var _o$obj6, _o$obj6$a$b; - return !!((_o$obj6 = o.obj) != null && (_o$obj6$a$b = _o$obj6.a.b) != null && _o$obj6$a$b.c.d); + var _o$obj6; + return !!((_o$obj6 = o.obj) != null && (_o$obj6 = _o$obj6.a.b) != null && _o$obj6.c.d); } static testLogicalInIf(o) { var _o$a$b4, _o$a; @@ -70,15 +70,15 @@ class C { } static testLogicalInReturn(o) { var _o$a$b5, _o$a2; - return (o == null ? void 0 : (_o$a$b5 = o.a.b) == null ? void 0 : _o$a$b5.c.d) && (o == null ? void 0 : (_o$a2 = o.a) == null ? void 0 : _o$a2.b.c.d); + return (o == null || (_o$a$b5 = o.a.b) == null ? void 0 : _o$a$b5.c.d) && (o == null || (_o$a2 = o.a) == null ? void 0 : _o$a2.b.c.d); } static testNullishCoalescing(o) { var _o$a$b$c$non_existent, _o$a$b6, _o$a$b7, _o$a$b$c$non_existent3, _o$a$b10; - if ((_o$a$b$c$non_existent = o == null ? void 0 : (_o$a$b6 = o.a.b) == null ? void 0 : _o$a$b6.c.non_existent) != null ? _o$a$b$c$non_existent : o == null ? void 0 : (_o$a$b7 = o.a.b) == null ? void 0 : _o$a$b7.c.d) { + if ((_o$a$b$c$non_existent = o == null || (_o$a$b6 = o.a.b) == null ? void 0 : _o$a$b6.c.non_existent) != null ? _o$a$b$c$non_existent : o == null || (_o$a$b7 = o.a.b) == null ? void 0 : _o$a$b7.c.d) { var _o$a$b$c$non_existent2, _o$a$b8, _o$a$b9; - return (_o$a$b$c$non_existent2 = o == null ? void 0 : (_o$a$b8 = o.a.b) == null ? void 0 : _o$a$b8.c.non_existent) != null ? _o$a$b$c$non_existent2 : o == null ? void 0 : (_o$a$b9 = o.a.b) == null ? void 0 : _o$a$b9.c.d; + return (_o$a$b$c$non_existent2 = o == null || (_o$a$b8 = o.a.b) == null ? void 0 : _o$a$b8.c.non_existent) != null ? _o$a$b$c$non_existent2 : o == null || (_o$a$b9 = o.a.b) == null ? void 0 : _o$a$b9.c.d; } - return (_o$a$b$c$non_existent3 = o == null ? void 0 : (_o$a$b10 = o.a.b) == null ? void 0 : _o$a$b10.c.non_existent) != null ? _o$a$b$c$non_existent3 : o; + return (_o$a$b$c$non_existent3 = o == null || (_o$a$b10 = o.a.b) == null ? void 0 : _o$a$b10.c.non_existent) != null ? _o$a$b$c$non_existent3 : o; } } C.test(); diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/in-function-params/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/in-function-params/output.js index 001a548c31b6..d8ac6c5cd096 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/in-function-params/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/in-function-params/output.js @@ -4,11 +4,11 @@ function g({ b = a == null ? void 0 : a.c }) {} function h(a, { - b = ((_a$b, _a$b$c) => (_a$b = a.b) == null ? void 0 : (_a$b$c = _a$b.c) == null ? void 0 : _a$b$c.d.e)() + b = (_a$b => (_a$b = a.b) == null || (_a$b = _a$b.c) == null ? void 0 : _a$b.d.e)() }) {} function i(a, { - b = ((_a$b2, _a$b2$c) => (_a$b2 = a.b) == null ? void 0 : (_a$b2$c = _a$b2.c) == null ? void 0 : _a$b2$c.d)().e + b = (_a$b2 => (_a$b2 = a.b) == null || (_a$b2 = _a$b2.c) == null ? void 0 : _a$b2.d)().e }) {} function j(a, { - b = (_a$b3 => a == null ? void 0 : (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e)() + b = (_a$b3 => a == null || (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e)() }) {} diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/memoize/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/memoize/output.js index a6890083e5e5..211081e930a5 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/memoize/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-noDocumentAll/memoize/output.js @@ -1,7 +1,7 @@ function test(foo) { var _foo$bar, _foo$get, _foo$bar2, _foo$bar3, _foo$bar$baz, _foo$bar4, _foo$bar$baz2, _foo$bar5, _foo$bar6, _foo$bar7, _foo$bar8, _foo$bar9, _foo$bar10, _foo$bar10$baz, _foo$bar11, _foo$bar11$baz; foo == null ? void 0 : foo.bar; - foo == null ? void 0 : (_foo$bar = foo.bar) == null ? void 0 : _foo$bar.baz; + foo == null || (_foo$bar = foo.bar) == null ? void 0 : _foo$bar.baz; foo == null ? void 0 : foo(foo); foo == null ? void 0 : foo.bar(); (_foo$get = foo.get(bar)) == null ? void 0 : _foo$get(); @@ -10,9 +10,9 @@ function test(foo) { (_foo$bar$baz = (_foo$bar4 = foo.bar()).baz) == null ? void 0 : _foo$bar$baz.call(_foo$bar4); (_foo$bar$baz2 = (_foo$bar5 = foo[bar]()).baz) == null ? void 0 : _foo$bar$baz2.call(_foo$bar5); (_foo$bar6 = foo.bar) == null ? void 0 : _foo$bar6.call(foo, foo.bar, false); - foo == null ? void 0 : (_foo$bar7 = foo.bar) == null ? void 0 : _foo$bar7.call(foo, foo.bar, true); + foo == null || (_foo$bar7 = foo.bar) == null ? void 0 : _foo$bar7.call(foo, foo.bar, true); (_foo$bar8 = foo.bar) == null ? void 0 : _foo$bar8.baz(foo.bar, false); - foo == null ? void 0 : (_foo$bar9 = foo.bar) == null ? void 0 : _foo$bar9.baz(foo.bar, true); - (_foo$bar10 = foo.bar) == null ? void 0 : (_foo$bar10$baz = _foo$bar10.baz) == null ? void 0 : _foo$bar10$baz.call(_foo$bar10, foo.bar, false); - foo == null ? void 0 : (_foo$bar11 = foo.bar) == null ? void 0 : (_foo$bar11$baz = _foo$bar11.baz) == null ? void 0 : _foo$bar11$baz.call(_foo$bar11, foo.bar, true); + foo == null || (_foo$bar9 = foo.bar) == null ? void 0 : _foo$bar9.baz(foo.bar, true); + (_foo$bar10 = foo.bar) == null || (_foo$bar10$baz = _foo$bar10.baz) == null ? void 0 : _foo$bar10$baz.call(_foo$bar10, foo.bar, false); + foo == null || (_foo$bar11 = foo.bar) == null || (_foo$bar11$baz = _foo$bar11.baz) == null ? void 0 : _foo$bar11$baz.call(_foo$bar11, foo.bar, true); } diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js index 6a53b705a465..0e495069f9a9 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/function-call/output.js @@ -1,11 +1,11 @@ -var _foo, _foo2, _foo3, _foo$bar, _foo4, _foo5, _foo5$bar; +var _foo, _foo2, _foo3, _foo$bar, _foo4, _foo5; foo === null || foo === void 0 ? void 0 : foo(foo); (_foo = foo) === null || _foo === void 0 ? void 0 : _foo.bar(); foo.bar === null || foo.bar === void 0 ? void 0 : foo.bar(foo.bar, false); -(_foo2 = foo) === null || _foo2 === void 0 ? void 0 : _foo2.bar === null || _foo2.bar === void 0 ? void 0 : _foo2.bar(foo.bar, true); +(_foo2 = foo) === null || _foo2 === void 0 || _foo2.bar === null || _foo2.bar === void 0 ? void 0 : _foo2.bar(foo.bar, true); foo === null || foo === void 0 ? void 0 : foo().bar; -foo === null || foo === void 0 ? void 0 : (_foo3 = foo()) === null || _foo3 === void 0 ? void 0 : _foo3.bar; +foo === null || foo === void 0 || (_foo3 = foo()) === null || _foo3 === void 0 ? void 0 : _foo3.bar; foo.bar === null || foo.bar === void 0 ? void 0 : foo.bar().baz; -foo.bar === null || foo.bar === void 0 ? void 0 : (_foo$bar = foo.bar()) === null || _foo$bar === void 0 ? void 0 : _foo$bar.baz; -(_foo4 = foo) === null || _foo4 === void 0 ? void 0 : _foo4.bar === null || _foo4.bar === void 0 ? void 0 : _foo4.bar().baz; -(_foo5 = foo) === null || _foo5 === void 0 ? void 0 : _foo5.bar === null || _foo5.bar === void 0 ? void 0 : (_foo5$bar = _foo5.bar()) === null || _foo5$bar === void 0 ? void 0 : _foo5$bar.baz; +foo.bar === null || foo.bar === void 0 || (_foo$bar = foo.bar()) === null || _foo$bar === void 0 ? void 0 : _foo$bar.baz; +(_foo4 = foo) === null || _foo4 === void 0 || _foo4.bar === null || _foo4.bar === void 0 ? void 0 : _foo4.bar().baz; +(_foo5 = foo) === null || _foo5 === void 0 || _foo5.bar === null || _foo5.bar === void 0 || (_foo5 = _foo5.bar()) === null || _foo5 === void 0 ? void 0 : _foo5.baz; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/memoize/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/memoize/output.js index 67d245d2e8e1..43014978abcf 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/memoize/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/assumption-pureGetters/memoize/output.js @@ -1,7 +1,7 @@ function test(foo) { var _foo$bar, _foo$get, _foo$bar2, _foo$bar3, _foo$bar$baz, _foo$bar4, _foo$bar$baz2, _foo$bar5, _foo$bar6, _foo$bar7, _foo$bar8, _foo$bar9; foo === null || foo === void 0 ? void 0 : foo.bar; - foo === null || foo === void 0 ? void 0 : (_foo$bar = foo.bar) === null || _foo$bar === void 0 ? void 0 : _foo$bar.baz; + foo === null || foo === void 0 || (_foo$bar = foo.bar) === null || _foo$bar === void 0 ? void 0 : _foo$bar.baz; foo === null || foo === void 0 ? void 0 : foo(foo); foo === null || foo === void 0 ? void 0 : foo.bar(); (_foo$get = foo.get(bar)) === null || _foo$get === void 0 ? void 0 : _foo$get(); @@ -10,9 +10,9 @@ function test(foo) { (_foo$bar$baz = (_foo$bar4 = foo.bar()).baz) === null || _foo$bar$baz === void 0 ? void 0 : _foo$bar$baz.call(_foo$bar4); (_foo$bar$baz2 = (_foo$bar5 = foo[bar]()).baz) === null || _foo$bar$baz2 === void 0 ? void 0 : _foo$bar$baz2.call(_foo$bar5); foo.bar === null || foo.bar === void 0 ? void 0 : foo.bar(foo.bar, false); - foo === null || foo === void 0 ? void 0 : foo.bar === null || foo.bar === void 0 ? void 0 : foo.bar(foo.bar, true); + foo === null || foo === void 0 || foo.bar === null || foo.bar === void 0 ? void 0 : foo.bar(foo.bar, true); (_foo$bar6 = foo.bar) === null || _foo$bar6 === void 0 ? void 0 : _foo$bar6.baz(foo.bar, false); - foo === null || foo === void 0 ? void 0 : (_foo$bar7 = foo.bar) === null || _foo$bar7 === void 0 ? void 0 : _foo$bar7.baz(foo.bar, true); - (_foo$bar8 = foo.bar) === null || _foo$bar8 === void 0 ? void 0 : _foo$bar8.baz === null || _foo$bar8.baz === void 0 ? void 0 : _foo$bar8.baz(foo.bar, false); - foo === null || foo === void 0 ? void 0 : (_foo$bar9 = foo.bar) === null || _foo$bar9 === void 0 ? void 0 : _foo$bar9.baz === null || _foo$bar9.baz === void 0 ? void 0 : _foo$bar9.baz(foo.bar, true); + foo === null || foo === void 0 || (_foo$bar7 = foo.bar) === null || _foo$bar7 === void 0 ? void 0 : _foo$bar7.baz(foo.bar, true); + (_foo$bar8 = foo.bar) === null || _foo$bar8 === void 0 || _foo$bar8.baz === null || _foo$bar8.baz === void 0 ? void 0 : _foo$bar8.baz(foo.bar, false); + foo === null || foo === void 0 || (_foo$bar9 = foo.bar) === null || _foo$bar9 === void 0 || _foo$bar9.baz === null || _foo$bar9.baz === void 0 ? void 0 : _foo$bar9.baz(foo.bar, true); } diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/assignment/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/assignment/output.js index d7cfa5c66863..d0b91866b968 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/assignment/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/assignment/output.js @@ -11,7 +11,7 @@ const obj = { } }; const a = obj === null || obj === void 0 ? void 0 : obj.a; -const b = obj === null || obj === void 0 ? void 0 : (_obj$a = obj.a) === null || _obj$a === void 0 ? void 0 : _obj$a.b; -const bad = obj === null || obj === void 0 ? void 0 : (_obj$b = obj.b) === null || _obj$b === void 0 ? void 0 : _obj$b.b; +const b = obj === null || obj === void 0 || (_obj$a = obj.a) === null || _obj$a === void 0 ? void 0 : _obj$a.b; +const bad = obj === null || obj === void 0 || (_obj$b = obj.b) === null || _obj$b === void 0 ? void 0 : _obj$b.b; let val; -val = obj === null || obj === void 0 ? void 0 : (_obj$a2 = obj.a) === null || _obj$a2 === void 0 ? void 0 : _obj$a2.b; +val = obj === null || obj === void 0 || (_obj$a2 = obj.a) === null || _obj$a2 === void 0 ? void 0 : _obj$a2.b; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/cast-to-boolean/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/cast-to-boolean/output.js index af096f4fd14f..0f704f657152 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/cast-to-boolean/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/cast-to-boolean/output.js @@ -30,36 +30,36 @@ class C { return !!(o !== null && o !== void 0 && (_o$a$b3 = o.a.b) !== null && _o$a$b3 !== void 0 && _o$a$b3.c.d); } static testIfDeep(o) { - var _o$obj, _o$obj$a$b; - if ((_o$obj = o.obj) !== null && _o$obj !== void 0 && (_o$obj$a$b = _o$obj.a.b) !== null && _o$obj$a$b !== void 0 && _o$obj$a$b.c.d) { + var _o$obj; + if ((_o$obj = o.obj) !== null && _o$obj !== void 0 && (_o$obj = _o$obj.a.b) !== null && _o$obj !== void 0 && _o$obj.c.d) { return true; } return false; } static testConditionalDeep(o) { - var _o$obj2, _o$obj2$a$b; - return (_o$obj2 = o.obj) !== null && _o$obj2 !== void 0 && (_o$obj2$a$b = _o$obj2.a.b) !== null && _o$obj2$a$b !== void 0 && _o$obj2$a$b.c.d ? true : false; + var _o$obj2; + return (_o$obj2 = o.obj) !== null && _o$obj2 !== void 0 && (_o$obj2 = _o$obj2.a.b) !== null && _o$obj2 !== void 0 && _o$obj2.c.d ? true : false; } static testLoopDeep(o) { while ((_o$obj3 = o.obj) !== null && _o$obj3 !== void 0 && _o$obj3.a.b.c.d) { var _o$obj3; - for (; (_o$obj4 = o.obj) !== null && _o$obj4 !== void 0 && (_o$obj4$a$b$c = _o$obj4.a.b.c) !== null && _o$obj4$a$b$c !== void 0 && _o$obj4$a$b$c.d;) { - var _o$obj4, _o$obj4$a$b$c; + for (; (_o$obj4 = o.obj) !== null && _o$obj4 !== void 0 && (_o$obj4 = _o$obj4.a.b.c) !== null && _o$obj4 !== void 0 && _o$obj4.d;) { + var _o$obj4; let i = 0; do { - var _o$obj5, _o$obj5$a$b; + var _o$obj5; i++; if (i === 2) { return true; } - } while ((_o$obj5 = o.obj) !== null && _o$obj5 !== void 0 && (_o$obj5$a$b = _o$obj5.a.b) !== null && _o$obj5$a$b !== void 0 && _o$obj5$a$b.c.d); + } while ((_o$obj5 = o.obj) !== null && _o$obj5 !== void 0 && (_o$obj5 = _o$obj5.a.b) !== null && _o$obj5 !== void 0 && _o$obj5.c.d); } } return false; } static testNegateDeep(o) { - var _o$obj6, _o$obj6$a$b; - return !!((_o$obj6 = o.obj) !== null && _o$obj6 !== void 0 && (_o$obj6$a$b = _o$obj6.a.b) !== null && _o$obj6$a$b !== void 0 && _o$obj6$a$b.c.d); + var _o$obj6; + return !!((_o$obj6 = o.obj) !== null && _o$obj6 !== void 0 && (_o$obj6 = _o$obj6.a.b) !== null && _o$obj6 !== void 0 && _o$obj6.c.d); } static testLogicalInIf(o) { var _o$a$b4, _o$a; @@ -70,15 +70,15 @@ class C { } static testLogicalInReturn(o) { var _o$a$b5, _o$a2; - return (o === null || o === void 0 ? void 0 : (_o$a$b5 = o.a.b) === null || _o$a$b5 === void 0 ? void 0 : _o$a$b5.c.d) && (o === null || o === void 0 ? void 0 : (_o$a2 = o.a) === null || _o$a2 === void 0 ? void 0 : _o$a2.b.c.d); + return (o === null || o === void 0 || (_o$a$b5 = o.a.b) === null || _o$a$b5 === void 0 ? void 0 : _o$a$b5.c.d) && (o === null || o === void 0 || (_o$a2 = o.a) === null || _o$a2 === void 0 ? void 0 : _o$a2.b.c.d); } static testNullishCoalescing(o) { var _o$a$b$c$non_existent, _o$a$b6, _o$a$b7, _o$a$b$c$non_existent3, _o$a$b10; - if ((_o$a$b$c$non_existent = o === null || o === void 0 ? void 0 : (_o$a$b6 = o.a.b) === null || _o$a$b6 === void 0 ? void 0 : _o$a$b6.c.non_existent) !== null && _o$a$b$c$non_existent !== void 0 ? _o$a$b$c$non_existent : o === null || o === void 0 ? void 0 : (_o$a$b7 = o.a.b) === null || _o$a$b7 === void 0 ? void 0 : _o$a$b7.c.d) { + if ((_o$a$b$c$non_existent = o === null || o === void 0 || (_o$a$b6 = o.a.b) === null || _o$a$b6 === void 0 ? void 0 : _o$a$b6.c.non_existent) !== null && _o$a$b$c$non_existent !== void 0 ? _o$a$b$c$non_existent : o === null || o === void 0 || (_o$a$b7 = o.a.b) === null || _o$a$b7 === void 0 ? void 0 : _o$a$b7.c.d) { var _o$a$b$c$non_existent2, _o$a$b8, _o$a$b9; - return (_o$a$b$c$non_existent2 = o === null || o === void 0 ? void 0 : (_o$a$b8 = o.a.b) === null || _o$a$b8 === void 0 ? void 0 : _o$a$b8.c.non_existent) !== null && _o$a$b$c$non_existent2 !== void 0 ? _o$a$b$c$non_existent2 : o === null || o === void 0 ? void 0 : (_o$a$b9 = o.a.b) === null || _o$a$b9 === void 0 ? void 0 : _o$a$b9.c.d; + return (_o$a$b$c$non_existent2 = o === null || o === void 0 || (_o$a$b8 = o.a.b) === null || _o$a$b8 === void 0 ? void 0 : _o$a$b8.c.non_existent) !== null && _o$a$b$c$non_existent2 !== void 0 ? _o$a$b$c$non_existent2 : o === null || o === void 0 || (_o$a$b9 = o.a.b) === null || _o$a$b9 === void 0 ? void 0 : _o$a$b9.c.d; } - return (_o$a$b$c$non_existent3 = o === null || o === void 0 ? void 0 : (_o$a$b10 = o.a.b) === null || _o$a$b10 === void 0 ? void 0 : _o$a$b10.c.non_existent) !== null && _o$a$b$c$non_existent3 !== void 0 ? _o$a$b$c$non_existent3 : o; + return (_o$a$b$c$non_existent3 = o === null || o === void 0 || (_o$a$b10 = o.a.b) === null || _o$a$b10 === void 0 ? void 0 : _o$a$b10.c.non_existent) !== null && _o$a$b$c$non_existent3 !== void 0 ? _o$a$b$c$non_existent3 : o; } } C.test(); diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete-in-function-params/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete-in-function-params/output.js index 506fb7319b3e..feb28fe33c2c 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete-in-function-params/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete-in-function-params/output.js @@ -1 +1 @@ -function f(x = (_a => (_a = a()) === null || _a === void 0 ? true : delete _a.b)()) {} +function f(x = (_a => (_a = a()) === null || _a === void 0 || delete _a.b)()) {} diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete/output.js index 1e337339dcae..38ca699ee83d 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/delete/output.js @@ -6,7 +6,7 @@ const obj = { b: 0 } }; -let test = obj === null || obj === void 0 ? true : (_obj$a = obj.a) === null || _obj$a === void 0 ? true : delete _obj$a.b; -test = obj === null || obj === void 0 ? true : delete obj.a.b; -test = obj === null || obj === void 0 ? true : (_obj$b = obj.b) === null || _obj$b === void 0 ? true : delete _obj$b.b; -obj === null || obj === void 0 ? true : delete obj.a; +let test = obj === null || obj === void 0 || (_obj$a = obj.a) === null || _obj$a === void 0 || delete _obj$a.b; +test = obj === null || obj === void 0 || delete obj.a.b; +test = obj === null || obj === void 0 || (_obj$b = obj.b) === null || _obj$b === void 0 || delete _obj$b.b; +obj === null || obj === void 0 || delete obj.a; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call-loose/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call-loose/output.js index ad430d1126cc..3d7555d573cf 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call-loose/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call-loose/output.js @@ -2,4 +2,4 @@ var _foo, _foo2; foo == null ? void 0 : foo(foo); (_foo = foo) == null ? void 0 : _foo.bar(); foo.bar == null ? void 0 : foo.bar(foo.bar, false); -(_foo2 = foo) == null ? void 0 : _foo2.bar == null ? void 0 : _foo2.bar(foo.bar, true); +(_foo2 = foo) == null || _foo2.bar == null ? void 0 : _foo2.bar(foo.bar, true); diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call/output.js index 344d3a2bfa3e..42050bf5a223 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/function-call/output.js @@ -1,11 +1,11 @@ -var _foo, _foo2, _foo$bar, _foo3, _foo4, _foo4$bar, _foo5, _foo6, _foo7, _foo$bar2, _foo8, _foo$bar3, _foo9, _foo$bar3$call, _foo10, _foo10$bar, _foo11, _foo11$bar, _foo11$bar$call; +var _foo, _foo2, _foo$bar, _foo3, _foo4, _foo4$bar, _foo5, _foo6, _foo$bar2, _foo7, _foo$bar3, _foo8, _foo9, _foo9$bar, _foo10, _foo10$bar; (_foo = foo) === null || _foo === void 0 ? void 0 : _foo(foo); (_foo2 = foo) === null || _foo2 === void 0 ? void 0 : _foo2.bar(); (_foo$bar = (_foo3 = foo).bar) === null || _foo$bar === void 0 ? void 0 : _foo$bar.call(_foo3, foo.bar, false); -(_foo4 = foo) === null || _foo4 === void 0 ? void 0 : (_foo4$bar = _foo4.bar) === null || _foo4$bar === void 0 ? void 0 : _foo4$bar.call(_foo4, foo.bar, true); +(_foo4 = foo) === null || _foo4 === void 0 || (_foo4$bar = _foo4.bar) === null || _foo4$bar === void 0 ? void 0 : _foo4$bar.call(_foo4, foo.bar, true); (_foo5 = foo) === null || _foo5 === void 0 ? void 0 : _foo5().bar; -(_foo6 = foo) === null || _foo6 === void 0 ? void 0 : (_foo7 = _foo6()) === null || _foo7 === void 0 ? void 0 : _foo7.bar; -(_foo$bar2 = (_foo8 = foo).bar) === null || _foo$bar2 === void 0 ? void 0 : _foo$bar2.call(_foo8).baz; -(_foo$bar3 = (_foo9 = foo).bar) === null || _foo$bar3 === void 0 ? void 0 : (_foo$bar3$call = _foo$bar3.call(_foo9)) === null || _foo$bar3$call === void 0 ? void 0 : _foo$bar3$call.baz; -(_foo10 = foo) === null || _foo10 === void 0 ? void 0 : (_foo10$bar = _foo10.bar) === null || _foo10$bar === void 0 ? void 0 : _foo10$bar.call(_foo10).baz; -(_foo11 = foo) === null || _foo11 === void 0 ? void 0 : (_foo11$bar = _foo11.bar) === null || _foo11$bar === void 0 ? void 0 : (_foo11$bar$call = _foo11$bar.call(_foo11)) === null || _foo11$bar$call === void 0 ? void 0 : _foo11$bar$call.baz; +(_foo6 = foo) === null || _foo6 === void 0 || (_foo6 = _foo6()) === null || _foo6 === void 0 ? void 0 : _foo6.bar; +(_foo$bar2 = (_foo7 = foo).bar) === null || _foo$bar2 === void 0 ? void 0 : _foo$bar2.call(_foo7).baz; +(_foo$bar3 = (_foo8 = foo).bar) === null || _foo$bar3 === void 0 || (_foo$bar3 = _foo$bar3.call(_foo8)) === null || _foo$bar3 === void 0 ? void 0 : _foo$bar3.baz; +(_foo9 = foo) === null || _foo9 === void 0 || (_foo9$bar = _foo9.bar) === null || _foo9$bar === void 0 ? void 0 : _foo9$bar.call(_foo9).baz; +(_foo10 = foo) === null || _foo10 === void 0 || (_foo10$bar = _foo10.bar) === null || _foo10$bar === void 0 || (_foo10$bar = _foo10$bar.call(_foo10)) === null || _foo10$bar === void 0 ? void 0 : _foo10$bar.baz; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params-loose/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params-loose/output.js index 001a548c31b6..d8ac6c5cd096 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params-loose/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params-loose/output.js @@ -4,11 +4,11 @@ function g({ b = a == null ? void 0 : a.c }) {} function h(a, { - b = ((_a$b, _a$b$c) => (_a$b = a.b) == null ? void 0 : (_a$b$c = _a$b.c) == null ? void 0 : _a$b$c.d.e)() + b = (_a$b => (_a$b = a.b) == null || (_a$b = _a$b.c) == null ? void 0 : _a$b.d.e)() }) {} function i(a, { - b = ((_a$b2, _a$b2$c) => (_a$b2 = a.b) == null ? void 0 : (_a$b2$c = _a$b2.c) == null ? void 0 : _a$b2$c.d)().e + b = (_a$b2 => (_a$b2 = a.b) == null || (_a$b2 = _a$b2.c) == null ? void 0 : _a$b2.d)().e }) {} function j(a, { - b = (_a$b3 => a == null ? void 0 : (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e)() + b = (_a$b3 => a == null || (_a$b3 = a.b) == null ? void 0 : _a$b3.c().d.e)() }) {} diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params/output.js index aa3e1ba282e0..bb66d18131d6 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/in-function-params/output.js @@ -4,11 +4,11 @@ function g({ b = a === null || a === void 0 ? void 0 : a.c }) {} function h(a, { - b = ((_a$b, _a$b$c) => (_a$b = a.b) === null || _a$b === void 0 ? void 0 : (_a$b$c = _a$b.c) === null || _a$b$c === void 0 ? void 0 : _a$b$c.d.e)() + b = (_a$b => (_a$b = a.b) === null || _a$b === void 0 || (_a$b = _a$b.c) === null || _a$b === void 0 ? void 0 : _a$b.d.e)() }) {} function i(a, { - b = ((_a$b2, _a$b2$c) => (_a$b2 = a.b) === null || _a$b2 === void 0 ? void 0 : (_a$b2$c = _a$b2.c) === null || _a$b2$c === void 0 ? void 0 : _a$b2$c.d)().e + b = (_a$b2 => (_a$b2 = a.b) === null || _a$b2 === void 0 || (_a$b2 = _a$b2.c) === null || _a$b2 === void 0 ? void 0 : _a$b2.d)().e }) {} function j(a, { - b = (_a$b3 => a === null || a === void 0 ? void 0 : (_a$b3 = a.b) === null || _a$b3 === void 0 ? void 0 : _a$b3.c().d.e)() + b = (_a$b3 => a === null || a === void 0 || (_a$b3 = a.b) === null || _a$b3 === void 0 ? void 0 : _a$b3.c().d.e)() }) {} diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/member-access/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/member-access/output.js index d0fe46cebca1..97c3c76e7571 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/member-access/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/member-access/output.js @@ -1,10 +1,10 @@ -var _foo, _a, _a$b$c, _a$b, _a$b$c$d, _a$b$c2, _a$b$c2$d, _orders, _orders2, _orders2$, _client, _orders$client$key, _a2, _c, _a3; +var _foo, _a, _a$b, _a$b$c, _orders, _orders2, _client, _orders$client$key, _a2, _c, _a3; (_foo = foo) === null || _foo === void 0 ? void 0 : _foo.bar; -(_a = a) === null || _a === void 0 ? void 0 : (_a$b$c = _a.b.c) === null || _a$b$c === void 0 ? void 0 : _a$b$c.d.e; -(_a$b = a.b) === null || _a$b === void 0 ? void 0 : (_a$b$c$d = _a$b.c.d) === null || _a$b$c$d === void 0 ? void 0 : _a$b$c$d.e; -(_a$b$c2 = a.b.c) === null || _a$b$c2 === void 0 ? void 0 : (_a$b$c2$d = _a$b$c2.d) === null || _a$b$c2$d === void 0 ? void 0 : _a$b$c2$d.e; +(_a = a) === null || _a === void 0 || (_a = _a.b.c) === null || _a === void 0 ? void 0 : _a.d.e; +(_a$b = a.b) === null || _a$b === void 0 || (_a$b = _a$b.c.d) === null || _a$b === void 0 ? void 0 : _a$b.e; +(_a$b$c = a.b.c) === null || _a$b$c === void 0 || (_a$b$c = _a$b$c.d) === null || _a$b$c === void 0 ? void 0 : _a$b$c.e; (_orders = orders) === null || _orders === void 0 ? void 0 : _orders[0].price; -(_orders2 = orders) === null || _orders2 === void 0 ? void 0 : (_orders2$ = _orders2[0]) === null || _orders2$ === void 0 ? void 0 : _orders2$.price; +(_orders2 = orders) === null || _orders2 === void 0 || (_orders2 = _orders2[0]) === null || _orders2 === void 0 ? void 0 : _orders2.price; orders[(_client = client) === null || _client === void 0 ? void 0 : _client.key].price; (_orders$client$key = orders[client.key]) === null || _orders$client$key === void 0 ? void 0 : _orders$client$key.price; (0, (_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b).c; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize-loose/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize-loose/output.js index 08076ece777c..b6340d0bd48b 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize-loose/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize-loose/output.js @@ -1,7 +1,7 @@ function test(foo) { var _foo$bar, _foo$get, _foo$bar2, _foo$bar3, _foo$bar$baz, _foo$bar4, _foo$bar$baz2, _foo$bar5, _foo$bar6, _foo$bar7, _foo$bar8, _foo$bar9; foo == null ? void 0 : foo.bar; - foo == null ? void 0 : (_foo$bar = foo.bar) == null ? void 0 : _foo$bar.baz; + foo == null || (_foo$bar = foo.bar) == null ? void 0 : _foo$bar.baz; foo == null ? void 0 : foo(foo); foo == null ? void 0 : foo.bar(); (_foo$get = foo.get(bar)) == null ? void 0 : _foo$get(); @@ -10,9 +10,9 @@ function test(foo) { (_foo$bar$baz = (_foo$bar4 = foo.bar()).baz) == null ? void 0 : _foo$bar$baz.call(_foo$bar4); (_foo$bar$baz2 = (_foo$bar5 = foo[bar]()).baz) == null ? void 0 : _foo$bar$baz2.call(_foo$bar5); foo.bar == null ? void 0 : foo.bar(foo.bar, false); - foo == null ? void 0 : foo.bar == null ? void 0 : foo.bar(foo.bar, true); + foo == null || foo.bar == null ? void 0 : foo.bar(foo.bar, true); (_foo$bar6 = foo.bar) == null ? void 0 : _foo$bar6.baz(foo.bar, false); - foo == null ? void 0 : (_foo$bar7 = foo.bar) == null ? void 0 : _foo$bar7.baz(foo.bar, true); - (_foo$bar8 = foo.bar) == null ? void 0 : _foo$bar8.baz == null ? void 0 : _foo$bar8.baz(foo.bar, false); - foo == null ? void 0 : (_foo$bar9 = foo.bar) == null ? void 0 : _foo$bar9.baz == null ? void 0 : _foo$bar9.baz(foo.bar, true); + foo == null || (_foo$bar7 = foo.bar) == null ? void 0 : _foo$bar7.baz(foo.bar, true); + (_foo$bar8 = foo.bar) == null || _foo$bar8.baz == null ? void 0 : _foo$bar8.baz(foo.bar, false); + foo == null || (_foo$bar9 = foo.bar) == null || _foo$bar9.baz == null ? void 0 : _foo$bar9.baz(foo.bar, true); } diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize/output.js index 45599e1c1062..979bd95a3e7e 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/memoize/output.js @@ -1,13 +1,13 @@ function test(foo) { var _foo$bar, _foo$bar2, _foo$bar3, _foo$bar4, _foo$bar5, _foo$bar6, _foo$bar6$baz, _foo$bar7, _foo$bar7$baz; foo === null || foo === void 0 ? void 0 : foo.bar; - foo === null || foo === void 0 ? void 0 : (_foo$bar = foo.bar) === null || _foo$bar === void 0 ? void 0 : _foo$bar.baz; + foo === null || foo === void 0 || (_foo$bar = foo.bar) === null || _foo$bar === void 0 ? void 0 : _foo$bar.baz; foo === null || foo === void 0 ? void 0 : foo(foo); foo === null || foo === void 0 ? void 0 : foo.bar(); (_foo$bar2 = foo.bar) === null || _foo$bar2 === void 0 ? void 0 : _foo$bar2.call(foo, foo.bar, false); - foo === null || foo === void 0 ? void 0 : (_foo$bar3 = foo.bar) === null || _foo$bar3 === void 0 ? void 0 : _foo$bar3.call(foo, foo.bar, true); + foo === null || foo === void 0 || (_foo$bar3 = foo.bar) === null || _foo$bar3 === void 0 ? void 0 : _foo$bar3.call(foo, foo.bar, true); (_foo$bar4 = foo.bar) === null || _foo$bar4 === void 0 ? void 0 : _foo$bar4.baz(foo.bar, false); - foo === null || foo === void 0 ? void 0 : (_foo$bar5 = foo.bar) === null || _foo$bar5 === void 0 ? void 0 : _foo$bar5.baz(foo.bar, true); - (_foo$bar6 = foo.bar) === null || _foo$bar6 === void 0 ? void 0 : (_foo$bar6$baz = _foo$bar6.baz) === null || _foo$bar6$baz === void 0 ? void 0 : _foo$bar6$baz.call(_foo$bar6, foo.bar, false); - foo === null || foo === void 0 ? void 0 : (_foo$bar7 = foo.bar) === null || _foo$bar7 === void 0 ? void 0 : (_foo$bar7$baz = _foo$bar7.baz) === null || _foo$bar7$baz === void 0 ? void 0 : _foo$bar7$baz.call(_foo$bar7, foo.bar, true); + foo === null || foo === void 0 || (_foo$bar5 = foo.bar) === null || _foo$bar5 === void 0 ? void 0 : _foo$bar5.baz(foo.bar, true); + (_foo$bar6 = foo.bar) === null || _foo$bar6 === void 0 || (_foo$bar6$baz = _foo$bar6.baz) === null || _foo$bar6$baz === void 0 ? void 0 : _foo$bar6$baz.call(_foo$bar6, foo.bar, false); + foo === null || foo === void 0 || (_foo$bar7 = foo.bar) === null || _foo$bar7 === void 0 || (_foo$bar7$baz = _foo$bar7.baz) === null || _foo$bar7$baz === void 0 ? void 0 : _foo$bar7$baz.call(_foo$bar7, foo.bar, true); } diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call-loose/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call-loose/output.js index 9df6ed350489..bdc341e0f352 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call-loose/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call-loose/output.js @@ -10,7 +10,7 @@ class Foo { return this; } test() { - var _o$Foo$self$getSelf, _o$Foo, _o$Foo$self$getSelf2, _o$Foo$self, _fn$Foo$self$getSelf, _fn, _fn$Foo, _fn$Foo$self$getSelf2, _fn$Foo$self; + var _o$Foo$self$getSelf, _o$Foo, _o$Foo$self$getSelf2, _o$Foo$self, _fn$Foo$self$getSelf, _fn, _fn$Foo$self$getSelf2, _fn$Foo$self; const Foo = this; const o = { Foo: Foo @@ -26,8 +26,8 @@ class Foo { (o == null ? void 0 : o.Foo.m.bind(o.Foo))().toString(); ((_o$Foo$self$getSelf = ((_o$Foo = o.Foo) == null ? void 0 : _o$Foo.self.getSelf.bind(_o$Foo.self))()) == null ? void 0 : _o$Foo$self$getSelf.m.bind(_o$Foo$self$getSelf))(); ((_o$Foo$self$getSelf2 = ((_o$Foo$self = o.Foo.self) == null ? void 0 : _o$Foo$self.getSelf.bind(_o$Foo$self))()) == null ? void 0 : _o$Foo$self$getSelf2.m.bind(_o$Foo$self$getSelf2))(); - ((_fn$Foo$self$getSelf = ((_fn = fn()) == null ? void 0 : (_fn$Foo = _fn.Foo) == null ? void 0 : _fn$Foo.self.getSelf.bind(_fn$Foo.self))()) == null ? void 0 : _fn$Foo$self$getSelf.m.bind(_fn$Foo$self$getSelf))(); - ((_fn$Foo$self$getSelf2 = (fn == null ? void 0 : (_fn$Foo$self = fn().Foo.self) == null ? void 0 : _fn$Foo$self.getSelf.bind(_fn$Foo$self))()) == null ? void 0 : _fn$Foo$self$getSelf2.m.bind(_fn$Foo$self$getSelf2))(); + ((_fn$Foo$self$getSelf = ((_fn = fn()) == null || (_fn = _fn.Foo) == null ? void 0 : _fn.self.getSelf.bind(_fn.self))()) == null ? void 0 : _fn$Foo$self$getSelf.m.bind(_fn$Foo$self$getSelf))(); + ((_fn$Foo$self$getSelf2 = (fn == null || (_fn$Foo$self = fn().Foo.self) == null ? void 0 : _fn$Foo$self.getSelf.bind(_fn$Foo$self))()) == null ? void 0 : _fn$Foo$self$getSelf2.m.bind(_fn$Foo$self$getSelf2))(); } } new Foo().test(); diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call/output.js index 840f8ec0c642..c8e36bdcdd33 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/parenthesized-member-call/output.js @@ -10,7 +10,7 @@ class Foo { return this; } test() { - var _o$Foo, _o$Foo2, _o$Foo3, _o$Foo$self$getSelf, _o$Foo4, _o$Foo4$self, _o$Foo$self$getSelf2, _o$Foo$self, _fn$Foo$self$getSelf, _fn, _fn$Foo, _fn$Foo$self, _fn$Foo$self$getSelf2, _fn$Foo$self2; + var _o$Foo, _o$Foo2, _o$Foo3, _o$Foo$self$getSelf, _o$Foo4, _o$Foo4$self, _o$Foo$self$getSelf2, _o$Foo$self, _fn$Foo$self$getSelf, _fn, _fn$self, _fn$Foo$self$getSelf2, _fn$Foo$self; const Foo = this; const o = { Foo: Foo @@ -26,8 +26,8 @@ class Foo { (o === null || o === void 0 ? void 0 : (_o$Foo3 = o.Foo).m.bind(_o$Foo3))().toString(); ((_o$Foo$self$getSelf = ((_o$Foo4 = o.Foo) === null || _o$Foo4 === void 0 ? void 0 : (_o$Foo4$self = _o$Foo4.self).getSelf.bind(_o$Foo4$self))()) === null || _o$Foo$self$getSelf === void 0 ? void 0 : _o$Foo$self$getSelf.m.bind(_o$Foo$self$getSelf))(); ((_o$Foo$self$getSelf2 = ((_o$Foo$self = o.Foo.self) === null || _o$Foo$self === void 0 ? void 0 : _o$Foo$self.getSelf.bind(_o$Foo$self))()) === null || _o$Foo$self$getSelf2 === void 0 ? void 0 : _o$Foo$self$getSelf2.m.bind(_o$Foo$self$getSelf2))(); - ((_fn$Foo$self$getSelf = ((_fn = fn()) === null || _fn === void 0 ? void 0 : (_fn$Foo = _fn.Foo) === null || _fn$Foo === void 0 ? void 0 : (_fn$Foo$self = _fn$Foo.self).getSelf.bind(_fn$Foo$self))()) === null || _fn$Foo$self$getSelf === void 0 ? void 0 : _fn$Foo$self$getSelf.m.bind(_fn$Foo$self$getSelf))(); - ((_fn$Foo$self$getSelf2 = (fn === null || fn === void 0 ? void 0 : (_fn$Foo$self2 = fn().Foo.self) === null || _fn$Foo$self2 === void 0 ? void 0 : _fn$Foo$self2.getSelf.bind(_fn$Foo$self2))()) === null || _fn$Foo$self$getSelf2 === void 0 ? void 0 : _fn$Foo$self$getSelf2.m.bind(_fn$Foo$self$getSelf2))(); + ((_fn$Foo$self$getSelf = ((_fn = fn()) === null || _fn === void 0 || (_fn = _fn.Foo) === null || _fn === void 0 ? void 0 : (_fn$self = _fn.self).getSelf.bind(_fn$self))()) === null || _fn$Foo$self$getSelf === void 0 ? void 0 : _fn$Foo$self$getSelf.m.bind(_fn$Foo$self$getSelf))(); + ((_fn$Foo$self$getSelf2 = (fn === null || fn === void 0 || (_fn$Foo$self = fn().Foo.self) === null || _fn$Foo$self === void 0 ? void 0 : _fn$Foo$self.getSelf.bind(_fn$Foo$self))()) === null || _fn$Foo$self$getSelf2 === void 0 ? void 0 : _fn$Foo$self$getSelf2.m.bind(_fn$Foo$self$getSelf2))(); } } new Foo().test(); diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/unary/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/unary/output.js index 91b957341cd9..55ddd288b122 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/unary/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/general/unary/output.js @@ -6,7 +6,7 @@ const obj = { b: 0 } }; -let test = +(obj === null || obj === void 0 ? void 0 : (_obj$a = obj.a) === null || _obj$a === void 0 ? void 0 : _obj$a.b); +let test = +(obj === null || obj === void 0 || (_obj$a = obj.a) === null || _obj$a === void 0 ? void 0 : _obj$a.b); test = +(obj === null || obj === void 0 ? void 0 : obj.a.b); -test = +(obj === null || obj === void 0 ? void 0 : (_obj$b = obj.b) === null || _obj$b === void 0 ? void 0 : _obj$b.b); -test = +(obj === null || obj === void 0 ? void 0 : (_obj$b2 = obj.b) === null || _obj$b2 === void 0 ? void 0 : _obj$b2.b); +test = +(obj === null || obj === void 0 || (_obj$b = obj.b) === null || _obj$b === void 0 ? void 0 : _obj$b.b); +test = +(obj === null || obj === void 0 || (_obj$b2 = obj.b) === null || _obj$b2 === void 0 ? void 0 : _obj$b2.b); diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/loose/cast-to-boolean/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/loose/cast-to-boolean/output.js index 635606664ba5..658de851ca70 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/loose/cast-to-boolean/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/loose/cast-to-boolean/output.js @@ -30,36 +30,36 @@ class C { return !!(o != null && (_o$a$b3 = o.a.b) != null && _o$a$b3.c.d); } static testIfDeep(o) { - var _o$obj, _o$obj$a$b; - if ((_o$obj = o.obj) != null && (_o$obj$a$b = _o$obj.a.b) != null && _o$obj$a$b.c.d) { + var _o$obj; + if ((_o$obj = o.obj) != null && (_o$obj = _o$obj.a.b) != null && _o$obj.c.d) { return true; } return false; } static testConditionalDeep(o) { - var _o$obj2, _o$obj2$a$b; - return (_o$obj2 = o.obj) != null && (_o$obj2$a$b = _o$obj2.a.b) != null && _o$obj2$a$b.c.d ? true : false; + var _o$obj2; + return (_o$obj2 = o.obj) != null && (_o$obj2 = _o$obj2.a.b) != null && _o$obj2.c.d ? true : false; } static testLoopDeep(o) { while ((_o$obj3 = o.obj) != null && _o$obj3.a.b.c.d) { var _o$obj3; - for (; (_o$obj4 = o.obj) != null && (_o$obj4$a$b$c = _o$obj4.a.b.c) != null && _o$obj4$a$b$c.d;) { - var _o$obj4, _o$obj4$a$b$c; + for (; (_o$obj4 = o.obj) != null && (_o$obj4 = _o$obj4.a.b.c) != null && _o$obj4.d;) { + var _o$obj4; let i = 0; do { - var _o$obj5, _o$obj5$a$b; + var _o$obj5; i++; if (i === 2) { return true; } - } while ((_o$obj5 = o.obj) != null && (_o$obj5$a$b = _o$obj5.a.b) != null && _o$obj5$a$b.c.d); + } while ((_o$obj5 = o.obj) != null && (_o$obj5 = _o$obj5.a.b) != null && _o$obj5.c.d); } } return false; } static testNegateDeep(o) { - var _o$obj6, _o$obj6$a$b; - return !!((_o$obj6 = o.obj) != null && (_o$obj6$a$b = _o$obj6.a.b) != null && _o$obj6$a$b.c.d); + var _o$obj6; + return !!((_o$obj6 = o.obj) != null && (_o$obj6 = _o$obj6.a.b) != null && _o$obj6.c.d); } static testLogicalInIf(o) { var _o$a$b4, _o$a; @@ -70,15 +70,15 @@ class C { } static testLogicalInReturn(o) { var _o$a$b5, _o$a2; - return (o == null ? void 0 : (_o$a$b5 = o.a.b) == null ? void 0 : _o$a$b5.c.d) && (o == null ? void 0 : (_o$a2 = o.a) == null ? void 0 : _o$a2.b.c.d); + return (o == null || (_o$a$b5 = o.a.b) == null ? void 0 : _o$a$b5.c.d) && (o == null || (_o$a2 = o.a) == null ? void 0 : _o$a2.b.c.d); } static testNullishCoalescing(o) { var _o$a$b$c$non_existent, _o$a$b6, _o$a$b7, _o$a$b$c$non_existent3, _o$a$b10; - if ((_o$a$b$c$non_existent = o == null ? void 0 : (_o$a$b6 = o.a.b) == null ? void 0 : _o$a$b6.c.non_existent) != null ? _o$a$b$c$non_existent : o == null ? void 0 : (_o$a$b7 = o.a.b) == null ? void 0 : _o$a$b7.c.d) { + if ((_o$a$b$c$non_existent = o == null || (_o$a$b6 = o.a.b) == null ? void 0 : _o$a$b6.c.non_existent) != null ? _o$a$b$c$non_existent : o == null || (_o$a$b7 = o.a.b) == null ? void 0 : _o$a$b7.c.d) { var _o$a$b$c$non_existent2, _o$a$b8, _o$a$b9; - return (_o$a$b$c$non_existent2 = o == null ? void 0 : (_o$a$b8 = o.a.b) == null ? void 0 : _o$a$b8.c.non_existent) != null ? _o$a$b$c$non_existent2 : o == null ? void 0 : (_o$a$b9 = o.a.b) == null ? void 0 : _o$a$b9.c.d; + return (_o$a$b$c$non_existent2 = o == null || (_o$a$b8 = o.a.b) == null ? void 0 : _o$a$b8.c.non_existent) != null ? _o$a$b$c$non_existent2 : o == null || (_o$a$b9 = o.a.b) == null ? void 0 : _o$a$b9.c.d; } - return (_o$a$b$c$non_existent3 = o == null ? void 0 : (_o$a$b10 = o.a.b) == null ? void 0 : _o$a$b10.c.non_existent) != null ? _o$a$b$c$non_existent3 : o; + return (_o$a$b$c$non_existent3 = o == null || (_o$a$b10 = o.a.b) == null ? void 0 : _o$a$b10.c.non_existent) != null ? _o$a$b$c$non_existent3 : o; } } C.test(); diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-optional-chaining/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-optional-chaining/output.js index 18f310d7b0ca..f526438a3f98 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-optional-chaining/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-optional-chaining/output.js @@ -1,9 +1,9 @@ -var _a, _a2, _a3, _b, _a4, _a4$b, _a5, _c, _a6, _a7; +var _a, _a2, _a3, _b, _a4, _a5, _a6, _a7; (_a = a) === null || _a === void 0 ? void 0 : _a.b!.c; (_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b!.c.d; (_a3 = a) === null || _a3 === void 0 ? void 0 : _a3.b.c!.d; (_b = a!.b) === null || _b === void 0 ? void 0 : _b.c; -(_a4 = a) === null || _a4 === void 0 ? void 0 : (_a4$b = _a4.b!) === null || _a4$b === void 0 ? void 0 : _a4$b.c; -(_a5 = a) === null || _a5 === void 0 ? void 0 : (_c = _a5.b!.c) === null || _c === void 0 ? void 0 : _c.c; +(_a4 = a) === null || _a4 === void 0 || (_a4 = _a4.b!) === null || _a4 === void 0 ? void 0 : _a4.c; +(_a5 = a) === null || _a5 === void 0 || (_a5 = _a5.b!.c) === null || _a5 === void 0 ? void 0 : _a5.c; ((_a6 = a) === null || _a6 === void 0 ? void 0 : _a6.b)!.c; ((_a7 = a) === null || _a7 === void 0 ? void 0 : _a7.b)!.c; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-ts-and-optional-chaining/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-ts-and-optional-chaining/output.js index 1c20033de6f4..1ed8d909524c 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-ts-and-optional-chaining/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/regression/10959-transform-ts-and-optional-chaining/output.js @@ -1,9 +1,9 @@ -var _a, _a2, _a3, _b, _a4, _a4$b, _a5, _c, _a6, _a7; +var _a, _a2, _a3, _b, _a4, _a5, _a6, _a7; (_a = a) === null || _a === void 0 ? void 0 : _a.b.c; (_a2 = a) === null || _a2 === void 0 ? void 0 : _a2.b.c.d; (_a3 = a) === null || _a3 === void 0 ? void 0 : _a3.b.c.d; (_b = a.b) === null || _b === void 0 ? void 0 : _b.c; -(_a4 = a) === null || _a4 === void 0 ? void 0 : (_a4$b = _a4.b) === null || _a4$b === void 0 ? void 0 : _a4$b.c; -(_a5 = a) === null || _a5 === void 0 ? void 0 : (_c = _a5.b.c) === null || _c === void 0 ? void 0 : _c.c; +(_a4 = a) === null || _a4 === void 0 || (_a4 = _a4.b) === null || _a4 === void 0 ? void 0 : _a4.c; +(_a5 = a) === null || _a5 === void 0 || (_a5 = _a5.b.c) === null || _a5 === void 0 ? void 0 : _a5.c; ((_a6 = a) === null || _a6 === void 0 ? void 0 : _a6.b).c; ((_a7 = a) === null || _a7 === void 0 ? void 0 : _a7.b).c; diff --git a/packages/babel-plugin-transform-optional-chaining/test/fixtures/transparent-expr-wrappers/ts-as-member-expression/output.js b/packages/babel-plugin-transform-optional-chaining/test/fixtures/transparent-expr-wrappers/ts-as-member-expression/output.js index badc0c9c79b1..1afd9d19bacf 100644 --- a/packages/babel-plugin-transform-optional-chaining/test/fixtures/transparent-expr-wrappers/ts-as-member-expression/output.js +++ b/packages/babel-plugin-transform-optional-chaining/test/fixtures/transparent-expr-wrappers/ts-as-member-expression/output.js @@ -1,2 +1,2 @@ -var _a, _a$b; -(((_a = a) === null || _a === void 0 ? void 0 : (_a$b = (_a.b as ExampleType)) === null || _a$b === void 0 ? void 0 : _a$b.c) as ExampleType2); +var _a; +(((_a = a) === null || _a === void 0 || (_a = (_a.b as ExampleType)) === null || _a === void 0 ? void 0 : _a.c) as ExampleType2); diff --git a/packages/babel-plugin-transform-typescript/test/fixtures/variable-declaration/non-null-in-optional-chain/output.js b/packages/babel-plugin-transform-typescript/test/fixtures/variable-declaration/non-null-in-optional-chain/output.js index bd88e0e09990..9f21c42560c5 100644 --- a/packages/babel-plugin-transform-typescript/test/fixtures/variable-declaration/non-null-in-optional-chain/output.js +++ b/packages/babel-plugin-transform-typescript/test/fixtures/variable-declaration/non-null-in-optional-chain/output.js @@ -1,5 +1,5 @@ const a = 1; const b = () => { var _a$b; - return a === null || a === void 0 ? void 0 : (_a$b = a.b) === null || _a$b === void 0 ? void 0 : _a$b.c.d; + return a === null || a === void 0 || (_a$b = a.b) === null || _a$b === void 0 ? void 0 : _a$b.c.d; };