Disallow reinitializing private elements (#13601)

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
This commit is contained in:
Felipe Armoni 2021-08-30 07:44:38 -03:00 committed by GitHub
parent cb3ebde8ce
commit fdfe97879e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
92 changed files with 451 additions and 229 deletions

View File

@ -540,16 +540,31 @@ function buildPrivateInstanceFieldInitSpec(
ref: t.Expression,
prop: NodePath<t.ClassPrivateProperty>,
privateNamesMap: PrivateNamesMap,
state,
) {
const { id } = privateNamesMap.get(prop.node.key.id.name);
const value = prop.node.value || prop.scope.buildUndefinedNode();
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,19 +647,47 @@ function buildPrivateInstanceMethodInitSpec(
ref: t.Expression,
prop: NodePath<t.ClassPrivateMethod>,
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) {
return buildPrivateAccessorInitialization(
ref,
prop,
privateNamesMap,
state,
);
}
return buildPrivateInstanceMethodInitalization(
ref,
prop,
privateNamesMap,
state,
);
}
function buildPrivateAccessorInitialization(
ref: t.Expression,
prop: NodePath<t.ClassPrivateMethod>,
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()},
@ -652,7 +695,39 @@ function buildPrivateInstanceMethodInitSpec(
});
`;
}
}
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<t.ClassPrivateMethod>,
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(

View File

@ -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();
}
}

View File

@ -0,0 +1,6 @@
{
"presets": [["env", { "shippedProposals": true }]],
"targets": {
"chrome": "75"
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -0,0 +1,6 @@
{
"presets": [["env", { "shippedProposals": true }]],
"targets": {
"chrome": "75"
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,15 @@
class Base {
constructor(obj) {
return obj;
}
}
class Derived extends Base {
#foo() {
return 'bar';
}
static get(obj) {
return obj.#foo();
}
}

View File

@ -0,0 +1,6 @@
{
"presets": [["env", { "shippedProposals": true }]],
"targets": {
"chrome": "75"
}
}

View File

@ -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';
}

View File

@ -2,7 +2,7 @@ var _privateMethod = /*#__PURE__*/new WeakSet();
class X {
constructor() {
_privateMethod.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _privateMethod);
}
}

View File

@ -3,8 +3,7 @@ var _foo = /*#__PURE__*/new WeakSet();
class A extends B {
constructor(...args) {
super(...args);
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
}
}

View File

@ -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")`

View File

@ -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);

View File

@ -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);

View File

@ -2,7 +2,7 @@ var _g = /*#__PURE__*/new WeakSet();
class C {
constructor() {
_g.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _g);
}
}

View File

@ -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
});

View File

@ -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
});

View File

@ -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;

View File

@ -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);
}

View File

@ -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";
};

View File

@ -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
});

View File

@ -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"
});

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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;
};

View File

@ -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),

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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
});

View File

@ -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;
}

View File

@ -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
});

View File

@ -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"
});

View File

@ -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
});

View File

@ -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)
});

View File

@ -2,7 +2,7 @@ var _bar = /*#__PURE__*/new WeakMap();
class Foo {
constructor() {
_bar.set(this, {
babelHelpers.classPrivateFieldInitSpec(this, _bar, {
writable: true,
value: "bar"
});

View File

@ -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
});

View File

@ -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
});

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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
});

View File

@ -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
});

View File

@ -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
});

View File

@ -2,7 +2,7 @@ var _m = /*#__PURE__*/new WeakMap();
class Foo {
constructor() {
_m.set(this, {
babelHelpers.classPrivateFieldInitSpec(this, _m, {
writable: true,
value: void 0
});

View File

@ -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
});

View File

@ -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"
});

View File

@ -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)
});

View File

@ -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* () {

View File

@ -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;
}

View File

@ -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));

View File

@ -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;
}

View File

@ -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
});

View File

@ -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
});

View File

@ -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}`
});

View File

@ -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";
}

View File

@ -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"));
}

View File

@ -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");
}

View File

@ -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");
}

View File

@ -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)``;
}

View File

@ -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";
}

View File

@ -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() {

View File

@ -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
});

View File

@ -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
});

View File

@ -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);
}

View File

@ -2,7 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet();
class Cl {
constructor() {
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
}
test() {

View File

@ -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)
});

View File

@ -2,7 +2,7 @@ var _foo;
console.log((_foo = /*#__PURE__*/new WeakSet(), class A {
constructor() {
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
}
method() {

View File

@ -2,8 +2,7 @@ var _getStatus = /*#__PURE__*/new WeakSet();
class Foo {
constructor(status) {
_getStatus.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _getStatus);
this.status = status;
}

View File

@ -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);

View File

@ -2,7 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet();
class Cl {
constructor() {
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
}
test() {

View File

@ -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];

View File

@ -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");
}

View File

@ -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() {

View File

@ -2,7 +2,7 @@ var _tag = /*#__PURE__*/new WeakSet();
class Foo {
constructor() {
_tag.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _tag);
}
}

View File

@ -2,7 +2,7 @@ var _bar = /*#__PURE__*/new WeakMap();
class Foo {
constructor() {
_bar.set(this, {
babelHelpers.classPrivateFieldInitSpec(this, _bar, {
writable: true,
value: "bar"
});

View File

@ -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
});

View File

@ -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
});

View File

@ -5,8 +5,7 @@ let Foo = /*#__PURE__*/function () {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
}
babelHelpers.createClass(Foo, [{

View File

@ -2,7 +2,7 @@ var _bar = /*#__PURE__*/new WeakMap();
class Foo {
constructor() {
_bar.set(this, {
babelHelpers.classPrivateFieldInitSpec(this, _bar, {
writable: true,
value: "bar"
});

View File

@ -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
});

View File

@ -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
});

View File

@ -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
});

View File

@ -2,8 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet();
class A {
constructor() {
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
babelHelpers.defineProperty(this, "x", 2);
}

View File

@ -2,8 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet();
class A {
constructor() {
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
babelHelpers.defineProperty(this, "x", 2);
}

View File

@ -2,8 +2,7 @@ var _foo = /*#__PURE__*/new WeakSet();
class A {
constructor() {
_foo.add(this);
babelHelpers.classPrivateMethodInitSpec(this, _foo);
babelHelpers.defineProperty(this, "x", 2);
}

View File

@ -2,7 +2,7 @@ var _foo = /*#__PURE__*/new WeakMap();
class A {
constructor() {
_foo.set(this, {
babelHelpers.classPrivateFieldInitSpec(this, _foo, {
writable: true,
value: void 0
});

View File

@ -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",

View File

@ -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",

View File

@ -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",