diff --git a/packages/babel-helper-member-expression-to-functions/src/index.js b/packages/babel-helper-member-expression-to-functions/src/index.js index 7724406d2b46..38c324731907 100644 --- a/packages/babel-helper-member-expression-to-functions/src/index.js +++ b/packages/babel-helper-member-expression-to-functions/src/index.js @@ -329,6 +329,8 @@ const handle = { return; } + // for (MEMBER of ARR) + // for (MEMBER in ARR) // { KEY: MEMBER } = OBJ -> { KEY: _destructureSet(MEMBER) } = OBJ // { KEY: MEMBER = _VALUE } = OBJ -> { KEY: _destructureSet(MEMBER) = _VALUE } = OBJ // {...MEMBER} -> {..._destructureSet(MEMBER)} @@ -337,6 +339,9 @@ const handle = { // [MEMBER = _VALUE] = ARR -> [_destructureSet(MEMBER) = _VALUE] = ARR // [...MEMBER] -> [..._destructureSet(MEMBER)] if ( + // for (MEMBER of ARR) + // for (MEMBER in ARR) + parentPath.isForXStatement({ left: node }) || // { KEY: MEMBER } = OBJ (parentPath.isObjectProperty({ value: node }) && parentPath.parentPath.isObjectPattern()) || diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/1-helpermemberexpressionfunction/input.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/1-helpermemberexpressionfunction/input.js new file mode 100644 index 000000000000..9defd1899e15 --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/1-helpermemberexpressionfunction/input.js @@ -0,0 +1,27 @@ +class D { + #arr; + f() { + for (const el of this.#arr); + } +} + +class C { + #p; + m() { + for (this.#p of []); + } +} + +class E { + #arr; + f() { + for (this.#arr of [1, 2]); + } +} + +class F { + #ar; + g() { + for (this.#ar in [1,2,3]); + } +} \ No newline at end of file diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/1-helpermemberexpressionfunction/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/1-helpermemberexpressionfunction/output.js new file mode 100644 index 000000000000..c956f5663c4e --- /dev/null +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/1-helpermemberexpressionfunction/output.js @@ -0,0 +1,99 @@ +var _arr = new WeakMap(); + +var D = /*#__PURE__*/function () { + "use strict"; + + function D() { + babelHelpers.classCallCheck(this, D); + + _arr.set(this, { + writable: true, + value: void 0 + }); + } + + babelHelpers.createClass(D, [{ + key: "f", + value: function f() { + for (var el of babelHelpers.classPrivateFieldGet(this, _arr)) { + ; + } + } + }]); + return D; +}(); + +var _p = new WeakMap(); + +var C = /*#__PURE__*/function () { + "use strict"; + + function C() { + babelHelpers.classCallCheck(this, C); + + _p.set(this, { + writable: true, + value: void 0 + }); + } + + babelHelpers.createClass(C, [{ + key: "m", + value: function m() { + for (babelHelpers.classPrivateFieldDestructureSet(this, _p).value of []) { + ; + } + } + }]); + return C; +}(); + +var _arr2 = new WeakMap(); + +var E = /*#__PURE__*/function () { + "use strict"; + + function E() { + babelHelpers.classCallCheck(this, E); + + _arr2.set(this, { + writable: true, + value: void 0 + }); + } + + babelHelpers.createClass(E, [{ + key: "f", + value: function f() { + for (babelHelpers.classPrivateFieldDestructureSet(this, _arr2).value of [1, 2]) { + ; + } + } + }]); + return E; +}(); + +var _ar = new WeakMap(); + +var F = /*#__PURE__*/function () { + "use strict"; + + function F() { + babelHelpers.classCallCheck(this, F); + + _ar.set(this, { + writable: true, + value: void 0 + }); + } + + babelHelpers.createClass(F, [{ + key: "g", + value: function g() { + for (babelHelpers.classPrivateFieldDestructureSet(this, _ar).value in [1, 2, 3]) { + ; + } + } + }]); + return F; +}();