diff --git a/packages/babel-helper-create-class-features-plugin/src/fields.ts b/packages/babel-helper-create-class-features-plugin/src/fields.ts index 0f500852c8..9d8b386aa9 100644 --- a/packages/babel-helper-create-class-features-plugin/src/fields.ts +++ b/packages/babel-helper-create-class-features-plugin/src/fields.ts @@ -540,16 +540,31 @@ function buildPrivateInstanceFieldInitSpec( ref: t.Expression, prop: NodePath, privateNamesMap: PrivateNamesMap, + state, ) { const { id } = privateNamesMap.get(prop.node.key.id.name); const value = prop.node.value || prop.scope.buildUndefinedNode(); - return template.statement.ast`${t.cloneNode(id)}.set(${ref}, { - // configurable is always false for private elements - // enumerable is always false for private elements - writable: true, - value: ${value}, - })`; + if (!process.env.BABEL_8_BREAKING) { + if (!state.availableHelper("classPrivateFieldInitSpec")) { + return template.statement.ast`${t.cloneNode(id)}.set(${ref}, { + // configurable is always false for private elements + // enumerable is always false for private elements + writable: true, + value: ${value}, + })`; + } + } + + const helper = state.addHelper("classPrivateFieldInitSpec"); + return template.statement.ast`${helper}( + ${t.thisExpression()}, + ${t.cloneNode(id)}, + { + writable: true, + value: ${value} + }, + )`; } function buildPrivateStaticFieldInitSpec( @@ -632,27 +647,87 @@ function buildPrivateInstanceMethodInitSpec( ref: t.Expression, prop: NodePath, privateNamesMap: PrivateNamesMap, + state, ) { const privateName = privateNamesMap.get(prop.node.key.id.name); - const { id, getId, setId, initAdded } = privateName; + const { getId, setId, initAdded } = privateName; if (initAdded) return; const isAccessor = getId || setId; if (isAccessor) { - privateNamesMap.set(prop.node.key.id.name, { - ...privateName, - initAdded: true, - }); + return buildPrivateAccessorInitialization( + ref, + prop, + privateNamesMap, + state, + ); + } - return template.statement.ast` + return buildPrivateInstanceMethodInitalization( + ref, + prop, + privateNamesMap, + state, + ); +} + +function buildPrivateAccessorInitialization( + ref: t.Expression, + prop: NodePath, + privateNamesMap: PrivateNamesMap, + state, +) { + const privateName = privateNamesMap.get(prop.node.key.id.name); + const { id, getId, setId } = privateName; + + privateNamesMap.set(prop.node.key.id.name, { + ...privateName, + initAdded: true, + }); + + if (!process.env.BABEL_8_BREAKING) { + if (!state.availableHelper("classPrivateFieldInitSpec")) { + return template.statement.ast` ${id}.set(${ref}, { get: ${getId ? getId.name : prop.scope.buildUndefinedNode()}, set: ${setId ? setId.name : prop.scope.buildUndefinedNode()} }); `; + } } - return template.statement.ast`${id}.add(${ref})`; + + const helper = state.addHelper("classPrivateFieldInitSpec"); + return template.statement.ast`${helper}( + ${t.thisExpression()}, + ${t.cloneNode(id)}, + { + get: ${getId ? getId.name : prop.scope.buildUndefinedNode()}, + set: ${setId ? setId.name : prop.scope.buildUndefinedNode()} + }, + )`; +} + +function buildPrivateInstanceMethodInitalization( + ref: t.Expression, + prop: NodePath, + privateNamesMap: PrivateNamesMap, + state, +) { + const privateName = privateNamesMap.get(prop.node.key.id.name); + const { id } = privateName; + + if (!process.env.BABEL_8_BREAKING) { + if (!state.availableHelper("classPrivateMethodInitSpec")) { + return template.statement.ast`${id}.add(${ref})`; + } + } + + const helper = state.addHelper("classPrivateMethodInitSpec"); + return template.statement.ast`${helper}( + ${t.thisExpression()}, + ${t.cloneNode(id)} + )`; } function buildPublicFieldInitLoose( @@ -957,6 +1032,7 @@ export function buildFieldsInitNodes( // @ts-expect-error checked in switch prop, privateNamesMap, + state, ), ); break; @@ -985,6 +1061,7 @@ export function buildFieldsInitNodes( // @ts-expect-error checked in switch prop, privateNamesMap, + state, ), ); pureStaticNodes.push( diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/input.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/input.js new file mode 100644 index 0000000000..8bc7070673 --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/input.js @@ -0,0 +1,19 @@ +class Base { + constructor(obj) { + return obj; + } +} + +class Derived extends Base { + get #foo() { + return 'bar'; + } + + set #foo(value) { + this.#foo = value; + } + + static get(obj) { + return obj.#foo(); + } +} diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/options.json b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/options.json new file mode 100644 index 0000000000..608f30af0e --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/options.json @@ -0,0 +1,6 @@ +{ + "presets": [["env", { "shippedProposals": true }]], + "targets": { + "chrome": "75" + } +} diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/output.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/output.js new file mode 100644 index 0000000000..f171007461 --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-accessor/output.js @@ -0,0 +1,31 @@ +class Base { + constructor(obj) { + return obj; + } + +} + +var _foo = /*#__PURE__*/new WeakMap(); + +class Derived extends Base { + constructor(...args) { + super(...args); + babelHelpers.classPrivateFieldInitSpec(this, _foo, { + get: _get_foo, + set: _set_foo + }); + } + + static get(obj) { + return babelHelpers.classPrivateFieldGet(obj, _foo).call(obj); + } + +} + +function _get_foo() { + return 'bar'; +} + +function _set_foo(value) { + babelHelpers.classPrivateFieldSet(this, _foo, value); +} diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/input.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/input.js new file mode 100644 index 0000000000..902695e4e9 --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/input.js @@ -0,0 +1,13 @@ +class Base { + constructor(obj) { + return obj; + } +} + +let counter = 0; +class Derived extends Base { + #foo = ++counter; + static get(obj) { + return obj.#foo; + } +} diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/options.json b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/options.json new file mode 100644 index 0000000000..608f30af0e --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/options.json @@ -0,0 +1,6 @@ +{ + "presets": [["env", { "shippedProposals": true }]], + "targets": { + "chrome": "75" + } +} diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/output.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/output.js new file mode 100644 index 0000000000..59fe05cc06 --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-field/output.js @@ -0,0 +1,25 @@ +class Base { + constructor(obj) { + return obj; + } + +} + +let counter = 0; + +var _foo = /*#__PURE__*/new WeakMap(); + +class Derived extends Base { + constructor(...args) { + super(...args); + babelHelpers.classPrivateFieldInitSpec(this, _foo, { + writable: true, + value: ++counter + }); + } + + static get(obj) { + return babelHelpers.classPrivateFieldGet(obj, _foo); + } + +} \ No newline at end of file diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/input.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/input.js new file mode 100644 index 0000000000..1d65290406 --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/input.js @@ -0,0 +1,15 @@ +class Base { + constructor(obj) { + return obj; + } +} + +class Derived extends Base { + #foo() { + return 'bar'; + } + + static get(obj) { + return obj.#foo(); + } +} diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/options.json b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/options.json new file mode 100644 index 0000000000..608f30af0e --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/options.json @@ -0,0 +1,6 @@ +{ + "presets": [["env", { "shippedProposals": true }]], + "targets": { + "chrome": "75" + } +} diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/output.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/output.js new file mode 100644 index 0000000000..f5dd07cc5e --- /dev/null +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/field-reinitialization/private-method/output.js @@ -0,0 +1,24 @@ +class Base { + constructor(obj) { + return obj; + } + +} + +var _foo = /*#__PURE__*/new WeakSet(); + +class Derived extends Base { + constructor(...args) { + super(...args); + babelHelpers.classPrivateMethodInitSpec(this, _foo); + } + + static get(obj) { + return babelHelpers.classPrivateMethodGet(obj, _foo, _foo2).call(obj); + } + +} + +function _foo2() { + return 'bar'; +} \ No newline at end of file diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/plugin-proposal-private-methods/loose-false/output.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/plugin-proposal-private-methods/loose-false/output.js index 6e921bc9e0..c74df0f555 100644 --- a/packages/babel-helper-create-class-features-plugin/test/fixtures/plugin-proposal-private-methods/loose-false/output.js +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/plugin-proposal-private-methods/loose-false/output.js @@ -2,7 +2,7 @@ var _privateMethod = /*#__PURE__*/new WeakSet(); class X { constructor() { - _privateMethod.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _privateMethod); } } diff --git a/packages/babel-helper-create-class-features-plugin/test/fixtures/replace-supers/method/output.js b/packages/babel-helper-create-class-features-plugin/test/fixtures/replace-supers/method/output.js index af58f2d3c9..07429bb7b2 100644 --- a/packages/babel-helper-create-class-features-plugin/test/fixtures/replace-supers/method/output.js +++ b/packages/babel-helper-create-class-features-plugin/test/fixtures/replace-supers/method/output.js @@ -3,8 +3,7 @@ var _foo = /*#__PURE__*/new WeakSet(); class A extends B { constructor(...args) { super(...args); - - _foo.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _foo); } } diff --git a/packages/babel-helpers/src/helpers.ts b/packages/babel-helpers/src/helpers.ts index 7385e63a71..0911aee766 100644 --- a/packages/babel-helpers/src/helpers.ts +++ b/packages/babel-helpers/src/helpers.ts @@ -2022,6 +2022,32 @@ helpers.classPrivateMethodGet = helper("7.1.6")` } `; +helpers.checkPrivateRedeclaration = helper("7.14.1")` + export default function _checkPrivateRedeclaration(obj, privateCollection) { + if (privateCollection.has(obj)) { + throw new TypeError("Cannot initialize the same private elements twice on an object"); + } + } +`; + +helpers.classPrivateFieldInitSpec = helper("7.14.1")` + import checkPrivateRedeclaration from "checkPrivateRedeclaration"; + + export default function _classPrivateFieldInitSpec(obj, privateMap, value) { + checkPrivateRedeclaration(obj, privateMap); + privateMap.set(obj, value); + } +`; + +helpers.classPrivateMethodInitSpec = helper("7.14.1")` + import checkPrivateRedeclaration from "checkPrivateRedeclaration"; + + export default function _classPrivateMethodInitSpec(obj, privateSet) { + checkPrivateRedeclaration(obj, privateSet); + privateSet.add(obj); + } +`; + if (!process.env.BABEL_8_BREAKING) { // Use readOnlyError instead helpers.classPrivateMethodSet = helper("7.1.6")` diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration-optional-chaining/output.mjs b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration-optional-chaining/output.mjs index b9c029038b..982de80500 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration-optional-chaining/output.mjs +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration-optional-chaining/output.mjs @@ -4,11 +4,10 @@ class C { constructor() { var _babelHelpers$classPr; - _m.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _m, { writable: true, value: void 0 }); - const o = null; const n = this; const p = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldGet(o, _m).call(o, ...c, 1); diff --git a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration/output.mjs b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration/output.mjs index b9c029038b..982de80500 100644 --- a/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration/output.mjs +++ b/packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining/test/fixtures/basic/class-private-integration/output.mjs @@ -4,11 +4,10 @@ class C { constructor() { var _babelHelpers$classPr; - _m.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _m, { writable: true, value: void 0 }); - const o = null; const n = this; const p = o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldGet(o, _m).call(o, ...c, 1); diff --git a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/output.js b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/output.js index edaf639ec2..92c4e90b13 100644 --- a/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/output.js +++ b/packages/babel-plugin-proposal-async-generator-functions/test/fixtures/async-generators/class-private-method/output.js @@ -2,7 +2,7 @@ var _g = /*#__PURE__*/new WeakSet(); class C { constructor() { - _g.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _g); } } 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 index 89ad20142e..ff85bfa459 100644 --- 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 @@ -5,8 +5,7 @@ var D = /*#__PURE__*/function () { function D() { babelHelpers.classCallCheck(this, D); - - _arr.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _arr, { writable: true, value: void 0 }); @@ -30,8 +29,7 @@ var C = /*#__PURE__*/function () { function C() { babelHelpers.classCallCheck(this, C); - - _p.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _p, { writable: true, value: void 0 }); @@ -55,8 +53,7 @@ var E = /*#__PURE__*/function () { function E() { babelHelpers.classCallCheck(this, E); - - _arr2.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _arr2, { writable: true, value: void 0 }); @@ -80,8 +77,7 @@ var F = /*#__PURE__*/function () { function F() { babelHelpers.classCallCheck(this, F); - - _ar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _ar, { writable: true, value: void 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/assignment/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/assignment/output.js index a7817db0ff..e0c46183b8 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/assignment/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/assignment/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/call/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/call/output.js index 27947d1df6..2b12c7ae9b 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/call/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/call/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: function () { return this; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/canonical/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/canonical/output.js index e41035c447..5fc50758bc 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/canonical/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/canonical/output.js @@ -7,17 +7,14 @@ var Point = /*#__PURE__*/function () { function Point(x = 0, y = 0) { babelHelpers.classCallCheck(this, Point); - - _x.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _x, { writable: true, value: void 0 }); - - _y.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _y, { writable: true, value: void 0 }); - babelHelpers.classPrivateFieldSet(this, _x, +x); babelHelpers.classPrivateFieldSet(this, _y, +y); } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/constructor-collision/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/constructor-collision/output.js index 05d01f4911..134fb98bde 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/constructor-collision/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/constructor-collision/output.js @@ -6,11 +6,9 @@ var Foo = function Foo() { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: foo }); - var _foo = "foo"; }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/declaration-order/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/declaration-order/output.js index b2c777ecc3..f3620fbdc8 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/declaration-order/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/declaration-order/output.js @@ -5,8 +5,7 @@ var C = function C() { babelHelpers.classCallCheck(this, C); babelHelpers.defineProperty(this, "y", babelHelpers.classPrivateFieldGet(this, _x)); - - _x.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _x, { writable: true, value: void 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived-multiple-supers/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived-multiple-supers/output.js index 06197e31d4..692b0bf2c2 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived-multiple-supers/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived-multiple-supers/output.js @@ -14,15 +14,13 @@ var Foo = /*#__PURE__*/function (_Bar) { if (condition) { _this = _super.call(this); - - _bar.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }); } else { _this = _super.call(this); - - _bar.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived/output.js index 97251962ae..d215894182 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/derived/output.js @@ -4,8 +4,7 @@ var Foo = function Foo() { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _prop.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _prop, { writable: true, value: "foo" }); @@ -25,12 +24,10 @@ var Bar = /*#__PURE__*/function (_Foo) { babelHelpers.classCallCheck(this, Bar); _this = _super.call(this, ...args); - - _prop2.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _prop2, { writable: true, value: "bar" }); - return _this; } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-1/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-1/output.js index 1b13a2e595..f8813d3f02 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-1/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-1/output.js @@ -4,12 +4,10 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - babelHelpers.classPrivateFieldSet(this, _client, 1); [this.x = babelHelpers.classPrivateFieldGet(this, _client), babelHelpers.classPrivateFieldDestructureSet(this, _client).value, this.y = babelHelpers.classPrivateFieldGet(this, _client)] = props; }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-2/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-2/output.js index 2ace67a331..9f88740d83 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-2/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-2/output.js @@ -4,11 +4,9 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - [x, ...babelHelpers.classPrivateFieldDestructureSet(this, _client).value] = props; }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-3/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-3/output.js index 6b9882ec1b..091bdecc0d 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-3/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern-3/output.js @@ -4,11 +4,9 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - [babelHelpers.classPrivateFieldDestructureSet(this, _client).value = 5] = props; }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern/output.js index ffeb7c001e..eeae89405a 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-array-pattern/output.js @@ -4,11 +4,9 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - [babelHelpers.classPrivateFieldDestructureSet(this, _client).value] = props; }; diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-1/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-1/output.js index bb48cc08e1..2522895f07 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-1/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-1/output.js @@ -4,12 +4,10 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - babelHelpers.classPrivateFieldSet(this, _client, 'foo'); ({ x: this.x = babelHelpers.classPrivateFieldGet(this, _client), diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-2/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-2/output.js index 1ffd2fe58f..94f7111188 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-2/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-2/output.js @@ -4,12 +4,10 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - ({ x, ...babelHelpers.classPrivateFieldDestructureSet(this, _client).value diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-3/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-3/output.js index 0c41925895..071bae2f50 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-3/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern-3/output.js @@ -4,12 +4,10 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - ({ x: babelHelpers.classPrivateFieldDestructureSet(this, _client).value = 5 } = props); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern/output.js index 7459b76bc9..6366d6e7f5 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/destructuring-object-pattern/output.js @@ -4,12 +4,10 @@ var Foo = function Foo(props) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _client.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _client, { writable: true, value: void 0 }); - ({ client: babelHelpers.classPrivateFieldDestructureSet(this, _client).value } = props); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/extracted-this/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/extracted-this/output.js index 1fb7de2ab4..5bbb120d1a 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/extracted-this/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/extracted-this/output.js @@ -8,13 +8,11 @@ var Foo = function Foo(_foo) { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: this }); - - _baz.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _baz, { writable: true, value: foo }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/foobar/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/foobar/output.js index 2ae9b573b3..496503850a 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/foobar/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/foobar/output.js @@ -12,14 +12,12 @@ var Child = /*#__PURE__*/function (_Parent) { babelHelpers.classCallCheck(this, Child); _this = _super.call(this); - - _scopedFunctionWithThis.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _scopedFunctionWithThis, { writable: true, value: () => { _this.name = {}; } }); - return _this; } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance-undefined/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance-undefined/output.js index 8c8ba57dec..dfa75cf39d 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance-undefined/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance-undefined/output.js @@ -4,8 +4,7 @@ var Foo = function Foo() { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: void 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance/output.js index c7208f4d74..c30d93994e 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/instance/output.js @@ -4,8 +4,7 @@ var Foo = function Foo() { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: "foo" }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/logical-assignment/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/logical-assignment/output.js index e61da807ce..012356bcec 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/logical-assignment/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/logical-assignment/output.js @@ -6,17 +6,15 @@ var _or = /*#__PURE__*/new WeakMap(); class Foo { constructor() { - _nullish.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _nullish, { writable: true, value: 0 }); - - _and.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _and, { writable: true, value: 0 }); - - _or.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _or, { writable: true, value: 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/multiple/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/multiple/output.js index fd609d4458..de23ee50d1 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/multiple/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/multiple/output.js @@ -6,13 +6,11 @@ var Foo = function Foo() { "use strict"; babelHelpers.classCallCheck(this, Foo); - - _x.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _x, { writable: true, value: 0 }); - - _y.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _y, { writable: true, value: babelHelpers.classPrivateFieldGet(this, _x) }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js index 98f4973499..cca3df0b1e 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/native-classes/output.js @@ -2,7 +2,7 @@ var _bar = /*#__PURE__*/new WeakMap(); class Foo { constructor() { - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: "bar" }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed-redeclared/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed-redeclared/output.js index 1dd4c23b4a..1f1a88576b 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed-redeclared/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed-redeclared/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); @@ -24,8 +23,7 @@ var Foo = /*#__PURE__*/function () { var Nested = /*#__PURE__*/function (_babelHelpers$classPr2) { function Nested() { babelHelpers.classCallCheck(this, Nested); - - _foo2.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo2, { writable: true, value: 2 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed/output.js index e5d21a9466..73762088ae 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-computed/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js index 816f80cbeb..05370b34fc 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed-redeclared/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); @@ -31,12 +30,10 @@ var Foo = /*#__PURE__*/function () { babelHelpers.classCallCheck(this, Nested); _this = _super.call(this, ...args); - - _foo2.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _foo2, { writable: true, value: 3 }); - return _this; } @@ -44,12 +41,10 @@ var Foo = /*#__PURE__*/function () { }((_foo3 = /*#__PURE__*/new WeakMap(), _babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _foo3), /*#__PURE__*/function () { function _class2() { babelHelpers.classCallCheck(this, _class2); - - _foo3.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo3, { writable: true, value: 2 }); - babelHelpers.defineProperty(this, _babelHelpers$classPr, 2); } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed/output.js index dddde36ed4..378e354e71 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-extends-computed/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); @@ -29,12 +28,10 @@ var Foo = /*#__PURE__*/function () { babelHelpers.classCallCheck(this, Nested); _this = _super.call(this, ...args); - - _foo2.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _foo2, { writable: true, value: 3 }); - return _this; } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-other-redeclared/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-other-redeclared/output.js index 080795751a..134b4cab21 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-other-redeclared/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-other-redeclared/output.js @@ -7,13 +7,11 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); - - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: 1 }); @@ -27,8 +25,7 @@ var Foo = /*#__PURE__*/function () { var Nested = /*#__PURE__*/function () { function Nested() { babelHelpers.classCallCheck(this, Nested); - - _bar2.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar2, { writable: true, value: 2 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-redeclared/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-redeclared/output.js index 1030037c7a..a507af4249 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-redeclared/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class-redeclared/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); @@ -20,8 +19,7 @@ var Foo = /*#__PURE__*/function () { var Nested = /*#__PURE__*/function () { function Nested() { babelHelpers.classCallCheck(this, Nested); - - _foo2.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo2, { writable: true, value: 2 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class/output.js index 69123eded4..df432fc79a 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/nested-class/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/optional-chain-member-optional-call-spread-arguments/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/optional-chain-member-optional-call-spread-arguments/output.js index 593a5772ca..58e1533d26 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/optional-chain-member-optional-call-spread-arguments/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/optional-chain-member-optional-call-spread-arguments/output.js @@ -2,7 +2,7 @@ var _m = /*#__PURE__*/new WeakMap(); class Foo { constructor() { - _m.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _m, { writable: true, value: void 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/private-in-derived/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/private-in-derived/output.js index 1e57996600..f2c1dbcfb0 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/private-in-derived/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/private-in-derived/output.js @@ -4,8 +4,7 @@ var Outer = function Outer() { "use strict"; babelHelpers.classCallCheck(this, Outer); - - _outer.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _outer, { writable: true, value: void 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js index 8c6a955412..6c22c5c9bf 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reevaluated/output.js @@ -3,7 +3,7 @@ function classFactory() { return _temp = (_foo = /*#__PURE__*/new WeakMap(), _class = class Foo { constructor() { - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: "foo" }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reference-in-other-property/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reference-in-other-property/output.js index 0b7476ce49..6c3d52803c 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reference-in-other-property/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/reference-in-other-property/output.js @@ -9,20 +9,16 @@ var Foo = function Foo() { babelHelpers.classCallCheck(this, Foo); babelHelpers.defineProperty(this, "one", babelHelpers.classPrivateFieldGet(this, _private)); - - _two.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _two, { writable: true, value: babelHelpers.classPrivateFieldGet(this, _private) }); - - _private.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _private, { writable: true, value: 0 }); - babelHelpers.defineProperty(this, "three", babelHelpers.classPrivateFieldGet(this, _private)); - - _four.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _four, { writable: true, value: babelHelpers.classPrivateFieldGet(this, _private) }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T7364/output.mjs b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T7364/output.mjs index ae07dabb78..7d23ce353b 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T7364/output.mjs +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/regression-T7364/output.mjs @@ -4,7 +4,7 @@ class MyClass { constructor() { var _this = this; - _myAsyncMethod.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _myAsyncMethod, { writable: true, value: function () { var _ref = babelHelpers.asyncToGenerator(function* () { @@ -26,7 +26,7 @@ var _myAsyncMethod2 = /*#__PURE__*/new WeakMap(); constructor() { var _this2 = this; - _myAsyncMethod2.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _myAsyncMethod2, { writable: true, value: function () { var _ref2 = babelHelpers.asyncToGenerator(function* () { @@ -48,7 +48,7 @@ export default class MyClass3 { constructor() { var _this3 = this; - _myAsyncMethod3.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _myAsyncMethod3, { writable: true, value: function () { var _ref3 = babelHelpers.asyncToGenerator(function* () { diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-call/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-call/output.js index 78bcdf3764..c329d248e3 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-call/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-call/output.js @@ -28,12 +28,10 @@ var B = /*#__PURE__*/function (_A) { babelHelpers.classCallCheck(this, B); _this = _super.call(this, ...args); - - _foo.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _foo, { writable: true, value: babelHelpers.get((_thisSuper = babelHelpers.assertThisInitialized(_this), babelHelpers.getPrototypeOf(B.prototype)), "foo", _thisSuper).call(_thisSuper) }); - return _this; } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-expression/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-expression/output.js index 1f17e973a2..d3b2bb1e9e 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-expression/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-expression/output.js @@ -11,7 +11,7 @@ var Foo = /*#__PURE__*/function (_Bar) { var _temp, _this; babelHelpers.classCallCheck(this, Foo); - foo((_temp = _this = _super.call(this), _bar.set(babelHelpers.assertThisInitialized(_this), { + foo((_temp = _this = _super.call(this), babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }), _temp)); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-statement/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-statement/output.js index e652b376af..310bfc691c 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-statement/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/super-statement/output.js @@ -12,12 +12,10 @@ var Foo = /*#__PURE__*/function (_Bar) { babelHelpers.classCallCheck(this, Foo); _this = _super.call(this); - - _bar.set(babelHelpers.assertThisInitialized(_this), { + babelHelpers.classPrivateFieldInitSpec(babelHelpers.assertThisInitialized(_this), _bar, { writable: true, value: "foo" }); - return _this; } diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/output.js index b06497c1fc..530024699b 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/tagged-template/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _tag.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _tag, { writable: true, value: void 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/update/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/update/output.js index 59d092de2d..cab004ed47 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/private/update/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/private/update/output.js @@ -5,8 +5,7 @@ var Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 0 }); diff --git a/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/output.js b/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/output.js index f41cc8189c..fc17c143e2 100644 --- a/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/output.js +++ b/packages/babel-plugin-proposal-class-properties/test/fixtures/regression/8882/output.js @@ -8,8 +8,7 @@ for (let i = 0; i <= 10; ++i) { classes.push((_temp = (_bar = /*#__PURE__*/new WeakMap(), _i = i, _class = class A { constructor() { babelHelpers.defineProperty(this, _i, `computed field ${i}`); - - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: `private field ${i}` }); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js index 658554a063..4b64a3333d 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/basic/output.js @@ -4,16 +4,14 @@ var _privateFieldValue = /*#__PURE__*/new WeakMap(); class Cl { constructor() { - _privateFieldValue.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateFieldValue, { get: _get_privateFieldValue, set: _set_privateFieldValue }); - - _privateField.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateField, { writable: true, value: "top secret string" }); - this.publicField = "not secret string"; } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js index 2a0691beef..6c95f5f1bb 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/get-only-setter/output.js @@ -4,16 +4,14 @@ var _privateFieldValue = /*#__PURE__*/new WeakMap(); class Cl { constructor() { - _privateFieldValue.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateFieldValue, { get: void 0, set: _set_privateFieldValue }); - - _privateField.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateField, { writable: true, value: 0 }); - this.publicField = (this, babelHelpers.writeOnlyError("#privateFieldValue")); } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/reassignment/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/reassignment/output.js index 4ee6f05ac8..3cd48da10e 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/reassignment/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/reassignment/output.js @@ -4,11 +4,10 @@ var _privateFieldValue = /*#__PURE__*/new WeakMap(); class Foo { constructor() { - _privateFieldValue.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateFieldValue, { get: _get_privateFieldValue, set: void 0 }); - this.self, results.push(2), babelHelpers.readOnlyError("#privateFieldValue"); } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js index 52a97f6ec2..99848e09ac 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/set-only-getter/output.js @@ -9,16 +9,14 @@ class Cl { } constructor() { - _privateFieldValue.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateFieldValue, { get: _get_privateFieldValue, set: void 0 }); - - _privateField.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateField, { writable: true, value: 0 }); - babelHelpers.defineProperty(this, "counter", 0); this.self, 1([babelHelpers.classPrivateFieldDestructureSet(this.self, _privateFieldValue).value] = [1]), babelHelpers.readOnlyError("#privateFieldValue"); } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/tagged-template/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/tagged-template/output.js index 90a909b22b..c8b534f929 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/tagged-template/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/tagged-template/output.js @@ -2,11 +2,10 @@ var _tag = /*#__PURE__*/new WeakMap(); class Foo { constructor() { - _tag.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _tag, { get: _get_tag, set: void 0 }); - babelHelpers.classPrivateFieldGet(this, _tag).bind(this)``; } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js index 0da9a9fc07..a3e609e11f 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/accessors/updates/output.js @@ -4,16 +4,14 @@ var _privateFieldValue = /*#__PURE__*/new WeakMap(); class Cl { constructor() { - _privateFieldValue.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateFieldValue, { get: _get_privateFieldValue, set: _set_privateFieldValue }); - - _privateField.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateField, { writable: true, value: "top secret string" }); - this.publicField = "not secret string"; } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/assumption-constantSuper/private-method-super/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/assumption-constantSuper/private-method-super/output.js index 74762cfc04..b0c6dcfb4a 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/assumption-constantSuper/private-method-super/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/assumption-constantSuper/private-method-super/output.js @@ -10,8 +10,7 @@ var _privateMethod = /*#__PURE__*/new WeakSet(); class Sub extends Base { constructor(...args) { super(...args); - - _privateMethod.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _privateMethod); } superMethod() { diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js index 995151f762..e4e64c0f34 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/get-set/output.js @@ -4,12 +4,11 @@ var _getSet = /*#__PURE__*/new WeakMap(); class Cl { constructor() { - _getSet.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _getSet, { get: _get_getSet, set: _set_getSet }); - - _privateField.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateField, { writable: true, value: 0 }); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js index 3c26592e76..10379c8a37 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/duplicated-names/set-get/output.js @@ -4,12 +4,11 @@ var _getSet = /*#__PURE__*/new WeakMap(); class Cl { constructor() { - _getSet.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _getSet, { get: _get_getSet, set: _set_getSet }); - - _privateField.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _privateField, { writable: true, value: 0 }); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js index 0c4c7958ab..368062ce9a 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/assignment/output.js @@ -2,8 +2,7 @@ var _privateMethod = /*#__PURE__*/new WeakSet(); class Foo { constructor() { - _privateMethod.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _privateMethod); this.publicField = babelHelpers.classPrivateMethodGet(this, _privateMethod, _privateMethod2).call(this); } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/async/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/async/output.js index 256f7fe629..13ee286f7c 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/async/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/async/output.js @@ -2,7 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet(); class Cl { constructor() { - _foo.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _foo); } test() { diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js index 447aba2a50..fe5a043218 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/before-fields/output.js @@ -4,11 +4,9 @@ var _method = /*#__PURE__*/new WeakSet(); class Cl { constructor() { - _method.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _method); babelHelpers.defineProperty(this, "prop", babelHelpers.classPrivateMethodGet(this, _method, _method2).call(this, 1)); - - _priv.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _priv, { writable: true, value: babelHelpers.classPrivateMethodGet(this, _method, _method2).call(this, 2) }); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/class-expression/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/class-expression/output.js index f0c034edfe..b177284a78 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/class-expression/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/class-expression/output.js @@ -2,7 +2,7 @@ var _foo; console.log((_foo = /*#__PURE__*/new WeakSet(), class A { constructor() { - _foo.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _foo); } method() { diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js index 0be6a465b0..9d96c81401 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/context/output.js @@ -2,8 +2,7 @@ var _getStatus = /*#__PURE__*/new WeakSet(); class Foo { constructor(status) { - _getStatus.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _getStatus); this.status = status; } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js index 88d1606b8f..cac29e2bd1 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/exfiltrated/output.js @@ -4,7 +4,7 @@ var _privateMethod = /*#__PURE__*/new WeakSet(); class Foo { constructor() { - _privateMethod.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _privateMethod); if (exfiltrated === undefined) { exfiltrated = babelHelpers.classPrivateMethodGet(this, _privateMethod, _privateMethod2); diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/generator/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/generator/output.js index 2d3984fd5d..565cde34ac 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/generator/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/generator/output.js @@ -2,7 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet(); class Cl { constructor() { - _foo.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _foo); } test() { diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/read-only/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/read-only/output.js index 9b9b5db279..cf55c30531 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/read-only/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/read-only/output.js @@ -7,8 +7,7 @@ class A { } constructor() { - _method.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _method); babelHelpers.defineProperty(this, "counter", 0); this.self(), 2, babelHelpers.readOnlyError("#method"); [babelHelpers.classPrivateFieldDestructureSet(this, _method).value] = [2]; diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/reassignment/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/reassignment/output.js index d06ddb53ec..6fc9d8e6bc 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/reassignment/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/reassignment/output.js @@ -4,8 +4,7 @@ var _privateFieldValue = /*#__PURE__*/new WeakSet(); class Foo { constructor() { - _privateFieldValue.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _privateFieldValue); this.self, results.push(2), babelHelpers.readOnlyError("#privateFieldValue"); } diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/super/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/super/output.js index 475654149f..25ba5547ff 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/super/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/super/output.js @@ -10,8 +10,7 @@ var _privateMethod = /*#__PURE__*/new WeakSet(); class Sub extends Base { constructor(...args) { super(...args); - - _privateMethod.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _privateMethod); } superMethod() { diff --git a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/tagged-template/output.js b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/tagged-template/output.js index 21029095ae..fb9580a3f9 100644 --- a/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/tagged-template/output.js +++ b/packages/babel-plugin-proposal-private-methods/test/fixtures/private-method/tagged-template/output.js @@ -2,7 +2,7 @@ var _tag = /*#__PURE__*/new WeakSet(); class Foo { constructor() { - _tag.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _tag); } } diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private-loose/native-classes/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private-loose/native-classes/output.js index 13ebbe4210..51e66218a8 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private-loose/native-classes/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private-loose/native-classes/output.js @@ -2,7 +2,7 @@ var _bar = /*#__PURE__*/new WeakMap(); class Foo { constructor() { - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: "bar" }); diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/accessor/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/accessor/output.js index 75a7587782..a5a7d2bc37 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/accessor/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/accessor/output.js @@ -5,8 +5,7 @@ let Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { get: _get_foo, set: void 0 }); diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/field/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/field/output.js index c83e48bcd8..b5206a1f38 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/field/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/field/output.js @@ -5,8 +5,7 @@ let Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/method/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/method/output.js index ac675cbf7d..32edd0cc6a 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/method/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/method/output.js @@ -5,8 +5,7 @@ let Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.add(this); + babelHelpers.classPrivateMethodInitSpec(this, _foo); } babelHelpers.createClass(Foo, [{ diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/native-classes/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/native-classes/output.js index 13ebbe4210..51e66218a8 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/native-classes/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/native-classes/output.js @@ -2,7 +2,7 @@ var _bar = /*#__PURE__*/new WeakMap(); class Foo { constructor() { - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: "bar" }); diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-other-redeclared/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-other-redeclared/output.js index a54b7a6691..82f59fa0b4 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-other-redeclared/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-other-redeclared/output.js @@ -7,13 +7,11 @@ let Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); - - _bar.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar, { writable: true, value: 1 }); @@ -27,8 +25,7 @@ let Foo = /*#__PURE__*/function () { let Nested = /*#__PURE__*/function () { function Nested() { babelHelpers.classCallCheck(this, Nested); - - _bar2.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _bar2, { writable: true, value: 2 }); diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-redeclared/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-redeclared/output.js index 20a7183234..b9c7cf2255 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-redeclared/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class-redeclared/output.js @@ -5,8 +5,7 @@ let Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); @@ -20,8 +19,7 @@ let Foo = /*#__PURE__*/function () { let Nested = /*#__PURE__*/function () { function Nested() { babelHelpers.classCallCheck(this, Nested); - - _foo2.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo2, { writable: true, value: 2 }); diff --git a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class/output.js b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class/output.js index 2c52c716a1..57550078e7 100644 --- a/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class/output.js +++ b/packages/babel-plugin-proposal-private-property-in-object/test/fixtures/private/nested-class/output.js @@ -5,8 +5,7 @@ let Foo = /*#__PURE__*/function () { function Foo() { babelHelpers.classCallCheck(this, Foo); - - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: 1 }); diff --git a/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/preset-not-loose-no-plugins/output.js b/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/preset-not-loose-no-plugins/output.js index f3de7b04fc..e411740434 100644 --- a/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/preset-not-loose-no-plugins/output.js +++ b/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/preset-not-loose-no-plugins/output.js @@ -2,8 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet(); class A { constructor() { - _foo.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _foo); babelHelpers.defineProperty(this, "x", 2); } diff --git a/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-and-methods-not-loose-preset-loose/output.js b/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-and-methods-not-loose-preset-loose/output.js index f3de7b04fc..e411740434 100644 --- a/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-and-methods-not-loose-preset-loose/output.js +++ b/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-and-methods-not-loose-preset-loose/output.js @@ -2,8 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet(); class A { constructor() { - _foo.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _foo); babelHelpers.defineProperty(this, "x", 2); } diff --git a/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-not-loose-preset-loose/output.js b/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-not-loose-preset-loose/output.js index f3de7b04fc..e411740434 100644 --- a/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-not-loose-preset-loose/output.js +++ b/packages/babel-preset-env/test/fixtures/loose-class-features-precedence/properties-not-loose-preset-loose/output.js @@ -2,8 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet(); class A { constructor() { - _foo.add(this); - + babelHelpers.classPrivateMethodInitSpec(this, _foo); babelHelpers.defineProperty(this, "x", 2); } diff --git a/packages/babel-preset-env/test/fixtures/shipped-proposals/new-class-features-firefox-70/output.js b/packages/babel-preset-env/test/fixtures/shipped-proposals/new-class-features-firefox-70/output.js index 458142957d..1cb775441e 100644 --- a/packages/babel-preset-env/test/fixtures/shipped-proposals/new-class-features-firefox-70/output.js +++ b/packages/babel-preset-env/test/fixtures/shipped-proposals/new-class-features-firefox-70/output.js @@ -2,7 +2,7 @@ var _foo = /*#__PURE__*/new WeakMap(); class A { constructor() { - _foo.set(this, { + babelHelpers.classPrivateFieldInitSpec(this, _foo, { writable: true, value: void 0 }); diff --git a/packages/babel-runtime-corejs2/package.json b/packages/babel-runtime-corejs2/package.json index 0c9b04e969..819ab3378c 100644 --- a/packages/babel-runtime-corejs2/package.json +++ b/packages/babel-runtime-corejs2/package.json @@ -801,6 +801,33 @@ "./helpers/classPrivateMethodGet.js" ], "./helpers/esm/classPrivateMethodGet": "./helpers/esm/classPrivateMethodGet.js", + "./helpers/checkPrivateRedeclaration": [ + { + "node": "./helpers/checkPrivateRedeclaration.js", + "import": "./helpers/esm/checkPrivateRedeclaration.js", + "default": "./helpers/checkPrivateRedeclaration.js" + }, + "./helpers/checkPrivateRedeclaration.js" + ], + "./helpers/esm/checkPrivateRedeclaration": "./helpers/esm/checkPrivateRedeclaration.js", + "./helpers/classPrivateFieldInitSpec": [ + { + "node": "./helpers/classPrivateFieldInitSpec.js", + "import": "./helpers/esm/classPrivateFieldInitSpec.js", + "default": "./helpers/classPrivateFieldInitSpec.js" + }, + "./helpers/classPrivateFieldInitSpec.js" + ], + "./helpers/esm/classPrivateFieldInitSpec": "./helpers/esm/classPrivateFieldInitSpec.js", + "./helpers/classPrivateMethodInitSpec": [ + { + "node": "./helpers/classPrivateMethodInitSpec.js", + "import": "./helpers/esm/classPrivateMethodInitSpec.js", + "default": "./helpers/classPrivateMethodInitSpec.js" + }, + "./helpers/classPrivateMethodInitSpec.js" + ], + "./helpers/esm/classPrivateMethodInitSpec": "./helpers/esm/classPrivateMethodInitSpec.js", "./helpers/classPrivateMethodSet": [ { "node": "./helpers/classPrivateMethodSet.js", diff --git a/packages/babel-runtime-corejs3/package.json b/packages/babel-runtime-corejs3/package.json index d0690a623e..8b4529b9c5 100644 --- a/packages/babel-runtime-corejs3/package.json +++ b/packages/babel-runtime-corejs3/package.json @@ -800,6 +800,33 @@ "./helpers/classPrivateMethodGet.js" ], "./helpers/esm/classPrivateMethodGet": "./helpers/esm/classPrivateMethodGet.js", + "./helpers/checkPrivateRedeclaration": [ + { + "node": "./helpers/checkPrivateRedeclaration.js", + "import": "./helpers/esm/checkPrivateRedeclaration.js", + "default": "./helpers/checkPrivateRedeclaration.js" + }, + "./helpers/checkPrivateRedeclaration.js" + ], + "./helpers/esm/checkPrivateRedeclaration": "./helpers/esm/checkPrivateRedeclaration.js", + "./helpers/classPrivateFieldInitSpec": [ + { + "node": "./helpers/classPrivateFieldInitSpec.js", + "import": "./helpers/esm/classPrivateFieldInitSpec.js", + "default": "./helpers/classPrivateFieldInitSpec.js" + }, + "./helpers/classPrivateFieldInitSpec.js" + ], + "./helpers/esm/classPrivateFieldInitSpec": "./helpers/esm/classPrivateFieldInitSpec.js", + "./helpers/classPrivateMethodInitSpec": [ + { + "node": "./helpers/classPrivateMethodInitSpec.js", + "import": "./helpers/esm/classPrivateMethodInitSpec.js", + "default": "./helpers/classPrivateMethodInitSpec.js" + }, + "./helpers/classPrivateMethodInitSpec.js" + ], + "./helpers/esm/classPrivateMethodInitSpec": "./helpers/esm/classPrivateMethodInitSpec.js", "./helpers/classPrivateMethodSet": [ { "node": "./helpers/classPrivateMethodSet.js", diff --git a/packages/babel-runtime/package.json b/packages/babel-runtime/package.json index c939ed29be..759a72f5b9 100644 --- a/packages/babel-runtime/package.json +++ b/packages/babel-runtime/package.json @@ -800,6 +800,33 @@ "./helpers/classPrivateMethodGet.js" ], "./helpers/esm/classPrivateMethodGet": "./helpers/esm/classPrivateMethodGet.js", + "./helpers/checkPrivateRedeclaration": [ + { + "node": "./helpers/checkPrivateRedeclaration.js", + "import": "./helpers/esm/checkPrivateRedeclaration.js", + "default": "./helpers/checkPrivateRedeclaration.js" + }, + "./helpers/checkPrivateRedeclaration.js" + ], + "./helpers/esm/checkPrivateRedeclaration": "./helpers/esm/checkPrivateRedeclaration.js", + "./helpers/classPrivateFieldInitSpec": [ + { + "node": "./helpers/classPrivateFieldInitSpec.js", + "import": "./helpers/esm/classPrivateFieldInitSpec.js", + "default": "./helpers/classPrivateFieldInitSpec.js" + }, + "./helpers/classPrivateFieldInitSpec.js" + ], + "./helpers/esm/classPrivateFieldInitSpec": "./helpers/esm/classPrivateFieldInitSpec.js", + "./helpers/classPrivateMethodInitSpec": [ + { + "node": "./helpers/classPrivateMethodInitSpec.js", + "import": "./helpers/esm/classPrivateMethodInitSpec.js", + "default": "./helpers/classPrivateMethodInitSpec.js" + }, + "./helpers/classPrivateMethodInitSpec.js" + ], + "./helpers/esm/classPrivateMethodInitSpec": "./helpers/esm/classPrivateMethodInitSpec.js", "./helpers/classPrivateMethodSet": [ { "node": "./helpers/classPrivateMethodSet.js",