Use function rather than var to compile private methods (#12990)

This commit is contained in:
Nicolò Ribaudo 2021-03-11 02:08:31 +01:00 committed by GitHub
parent b3e2bcda73
commit 8ad6b75cde
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
128 changed files with 417 additions and 300 deletions

View File

@ -625,46 +625,34 @@ function buildPrivateMethodDeclaration(
static: isStatic, static: isStatic,
} = privateName; } = privateName;
const { params, body, generator, async } = prop.node; const { params, body, generator, async } = prop.node;
const methodValue = t.functionExpression(
methodId,
params,
body,
generator,
async,
);
const isGetter = getId && !getterDeclared && params.length === 0; const isGetter = getId && !getterDeclared && params.length === 0;
const isSetter = setId && !setterDeclared && params.length > 0; const isSetter = setId && !setterDeclared && params.length > 0;
let declId = methodId;
if (isGetter) { if (isGetter) {
privateNamesMap.set(prop.node.key.id.name, { privateNamesMap.set(prop.node.key.id.name, {
...privateName, ...privateName,
getterDeclared: true, getterDeclared: true,
}); });
return t.variableDeclaration("var", [ declId = getId;
t.variableDeclarator(getId, methodValue), } else if (isSetter) {
]);
}
if (isSetter) {
privateNamesMap.set(prop.node.key.id.name, { privateNamesMap.set(prop.node.key.id.name, {
...privateName, ...privateName,
setterDeclared: true, setterDeclared: true,
}); });
return t.variableDeclaration("var", [ declId = setId;
t.variableDeclarator(setId, methodValue), } else if (isStatic && !privateFieldsAsProperties) {
]); declId = id;
}
if (isStatic && !privateFieldsAsProperties) {
return t.variableDeclaration("var", [
t.variableDeclarator(
t.cloneNode(id),
t.functionExpression(id, params, body, generator, async),
),
]);
} }
return t.variableDeclaration("var", [ return t.functionDeclaration(
t.variableDeclarator(t.cloneNode(methodId), methodValue), t.cloneNode(declId),
]); params,
body,
generator,
async,
);
} }
const thisContextVisitor = traverse.visitors.merge([ const thisContextVisitor = traverse.visitors.merge([
@ -710,9 +698,11 @@ export function buildFieldsInitNodes(
privateFieldsAsProperties, privateFieldsAsProperties,
constantSuper, constantSuper,
) { ) {
let needsClassRef = false;
const staticNodes = []; const staticNodes = [];
const instanceNodes = []; const instanceNodes = [];
let needsClassRef = false; // These nodes are pure and can be moved to the closest statement position
const pureStaticNodes = [];
for (const prop of props) { for (const prop of props) {
ts.assertFieldTransformed(prop); ts.assertFieldTransformed(prop);
@ -780,7 +770,7 @@ export function buildFieldsInitNodes(
privateNamesMap, privateNamesMap,
), ),
); );
staticNodes.push( pureStaticNodes.push(
buildPrivateMethodDeclaration( buildPrivateMethodDeclaration(
prop, prop,
privateNamesMap, privateNamesMap,
@ -796,7 +786,7 @@ export function buildFieldsInitNodes(
privateNamesMap, privateNamesMap,
), ),
); );
staticNodes.push( pureStaticNodes.push(
buildPrivateMethodDeclaration( buildPrivateMethodDeclaration(
prop, prop,
privateNamesMap, privateNamesMap,
@ -809,7 +799,7 @@ export function buildFieldsInitNodes(
staticNodes.unshift( staticNodes.unshift(
buildPrivateStaticFieldInitSpec(prop, privateNamesMap), buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
); );
staticNodes.unshift( pureStaticNodes.push(
buildPrivateMethodDeclaration( buildPrivateMethodDeclaration(
prop, prop,
privateNamesMap, privateNamesMap,
@ -827,7 +817,7 @@ export function buildFieldsInitNodes(
privateNamesMap, privateNamesMap,
), ),
); );
staticNodes.unshift( pureStaticNodes.push(
buildPrivateMethodDeclaration( buildPrivateMethodDeclaration(
prop, prop,
privateNamesMap, privateNamesMap,
@ -851,6 +841,7 @@ export function buildFieldsInitNodes(
return { return {
staticNodes: staticNodes.filter(Boolean), staticNodes: staticNodes.filter(Boolean),
instanceNodes: instanceNodes.filter(Boolean), instanceNodes: instanceNodes.filter(Boolean),
pureStaticNodes: pureStaticNodes.filter(Boolean),
wrapClass(path) { wrapClass(path) {
for (const prop of props) { for (const prop of props) {
prop.remove(); prop.remove();

View File

@ -198,10 +198,10 @@ export function createClassFeaturePlugin({
state, state,
); );
let keysNodes, staticNodes, instanceNodes, wrapClass; let keysNodes, staticNodes, pureStaticNodes, instanceNodes, wrapClass;
if (isDecorated) { if (isDecorated) {
staticNodes = keysNodes = []; staticNodes = pureStaticNodes = keysNodes = [];
({ instanceNodes, wrapClass } = buildDecoratedClass( ({ instanceNodes, wrapClass } = buildDecoratedClass(
ref, ref,
path, path,
@ -210,7 +210,12 @@ export function createClassFeaturePlugin({
)); ));
} else { } else {
keysNodes = extractComputedKeys(ref, path, computedPaths, this.file); keysNodes = extractComputedKeys(ref, path, computedPaths, this.file);
({ staticNodes, instanceNodes, wrapClass } = buildFieldsInitNodes( ({
staticNodes,
pureStaticNodes,
instanceNodes,
wrapClass,
} = buildFieldsInitNodes(
ref, ref,
path.node.superClass, path.node.superClass,
props, props,
@ -239,7 +244,14 @@ export function createClassFeaturePlugin({
path = wrapClass(path); path = wrapClass(path);
path.insertBefore([...privateNamesNodes, ...keysNodes]); path.insertBefore([...privateNamesNodes, ...keysNodes]);
path.insertAfter(staticNodes); if (staticNodes.length > 0) {
path.insertAfter(staticNodes);
}
if (pureStaticNodes.length > 0) {
path
.find(parent => parent.isStatement() || parent.isDeclaration())
.insertAfter(pureStaticNodes);
}
}, },
PrivateName(path) { PrivateName(path) {

View File

@ -7,6 +7,6 @@ class X {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return 42; return 42;
}; }

View File

@ -9,6 +9,6 @@ class X {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return 42; return 42;
}; }

View File

@ -9,8 +9,8 @@ class A extends B {
} }
var _foo2 = function _foo2() { function _foo2() {
let _A; let _A;
babelHelpers.get(babelHelpers.getPrototypeOf(A.prototype), "x", this); babelHelpers.get(babelHelpers.getPrototypeOf(A.prototype), "x", this);
}; }

View File

@ -7,7 +7,7 @@ class C {
} }
var _g2 = function _g2() { function _g2() {
var _this = this; var _this = this;
return babelHelpers.wrapAsyncGenerator(function* () { return babelHelpers.wrapAsyncGenerator(function* () {
@ -16,4 +16,4 @@ var _g2 = function _g2() {
yield 2; yield 2;
return 3; return 3;
})(); })();
}; }

View File

@ -1,18 +1,18 @@
var _class, _descriptor, _descriptor2, _temp; var _class, _descriptor, _descriptor2;
function dec() {} // Create a local function binding so babel has to change the name of the helper function dec() {} // Create a local function binding so babel has to change the name of the helper
function _defineProperty() {} function _defineProperty() {}
let A = (_class = (_temp = function A() { let A = (_class = function A() {
"use strict"; "use strict";
babelHelpers.classCallCheck(this, A); babelHelpers.classCallCheck(this, A);
babelHelpers.initializerDefineProperty(this, "a", _descriptor, this); babelHelpers.initializerDefineProperty(this, "a", _descriptor, this);
babelHelpers.initializerDefineProperty(this, "b", _descriptor2, this); babelHelpers.initializerDefineProperty(this, "b", _descriptor2, this);
babelHelpers.defineProperty(this, "c", 456); babelHelpers.defineProperty(this, "c", 456);
}, _temp), (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], { }, (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], {
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,

View File

@ -1,15 +1,15 @@
var _class, _descriptor, _descriptor2, _temp; var _class, _descriptor, _descriptor2;
function dec() {} function dec() {}
let A = (_class = (_temp = function A() { let A = (_class = function A() {
"use strict"; "use strict";
babelHelpers.classCallCheck(this, A); babelHelpers.classCallCheck(this, A);
babelHelpers.initializerDefineProperty(this, "a", _descriptor, this); babelHelpers.initializerDefineProperty(this, "a", _descriptor, this);
babelHelpers.initializerDefineProperty(this, "b", _descriptor2, this); babelHelpers.initializerDefineProperty(this, "b", _descriptor2, this);
this.c = 456; this.c = 456;
}, _temp), (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], { }, (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], {
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,

View File

@ -1,15 +1,15 @@
var _class, _descriptor, _descriptor2, _temp; var _class, _descriptor, _descriptor2;
function dec() {} function dec() {}
let A = (_class = (_temp = function A() { let A = (_class = function A() {
"use strict"; "use strict";
babelHelpers.classCallCheck(this, A); babelHelpers.classCallCheck(this, A);
babelHelpers.initializerDefineProperty(this, "a", _descriptor, this); babelHelpers.initializerDefineProperty(this, "a", _descriptor, this);
babelHelpers.initializerDefineProperty(this, "b", _descriptor2, this); babelHelpers.initializerDefineProperty(this, "b", _descriptor2, this);
babelHelpers.defineProperty(this, "c", 456); babelHelpers.defineProperty(this, "c", 456);
}, _temp), (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], { }, (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], {
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,

View File

@ -14,7 +14,7 @@ var Foo = /*#__PURE__*/function () {
babelHelpers.createClass(Foo, [{ babelHelpers.createClass(Foo, [{
key: "test", key: "test",
value: function test() { value: function test() {
var _foo3, _temp; var _foo3;
var _babelHelpers$classPr; var _babelHelpers$classPr;
@ -38,7 +38,7 @@ var Foo = /*#__PURE__*/function () {
} }
return Nested; return Nested;
}((_temp = (_foo3 = babelHelpers.classPrivateFieldLooseKey("foo"), _babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(this, _foo3)[_foo3], /*#__PURE__*/function () { }((_foo3 = babelHelpers.classPrivateFieldLooseKey("foo"), _babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(this, _foo3)[_foo3], /*#__PURE__*/function () {
function _class2() { function _class2() {
babelHelpers.classCallCheck(this, _class2); babelHelpers.classCallCheck(this, _class2);
Object.defineProperty(this, _foo3, { Object.defineProperty(this, _foo3, {
@ -49,7 +49,7 @@ var Foo = /*#__PURE__*/function () {
} }
return _class2; return _class2;
}()), _temp)); }()));
} }
}]); }]);
return Foo; return Foo;

View File

@ -14,8 +14,6 @@ var Foo = /*#__PURE__*/function () {
babelHelpers.createClass(Foo, [{ babelHelpers.createClass(Foo, [{
key: "test", key: "test",
value: function test() { value: function test() {
var _temp;
var _babelHelpers$classPr; var _babelHelpers$classPr;
var _foo2 = babelHelpers.classPrivateFieldLooseKey("foo"); var _foo2 = babelHelpers.classPrivateFieldLooseKey("foo");
@ -38,14 +36,14 @@ var Foo = /*#__PURE__*/function () {
} }
return Nested; return Nested;
}((_temp = (_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo], /*#__PURE__*/function () { }((_babelHelpers$classPr = babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo], /*#__PURE__*/function () {
function _class2() { function _class2() {
babelHelpers.classCallCheck(this, _class2); babelHelpers.classCallCheck(this, _class2);
this[_babelHelpers$classPr] = 2; this[_babelHelpers$classPr] = 2;
} }
return _class2; return _class2;
}()), _temp)); }()));
} }
}]); }]);
return Foo; return Foo;

View File

@ -15,7 +15,7 @@ var Foo = /*#__PURE__*/function () {
babelHelpers.createClass(Foo, [{ babelHelpers.createClass(Foo, [{
key: "test", key: "test",
value: function test() { value: function test() {
var _foo3, _temp; var _foo3;
var _babelHelpers$classPr; var _babelHelpers$classPr;
@ -41,7 +41,7 @@ var Foo = /*#__PURE__*/function () {
} }
return Nested; return Nested;
}((_temp = (_foo3 = new WeakMap(), _babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _foo3), /*#__PURE__*/function () { }((_foo3 = new WeakMap(), _babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _foo3), /*#__PURE__*/function () {
function _class2() { function _class2() {
babelHelpers.classCallCheck(this, _class2); babelHelpers.classCallCheck(this, _class2);
@ -54,7 +54,7 @@ var Foo = /*#__PURE__*/function () {
} }
return _class2; return _class2;
}()), _temp)); }()));
} }
}]); }]);
return Foo; return Foo;

View File

@ -15,8 +15,6 @@ var Foo = /*#__PURE__*/function () {
babelHelpers.createClass(Foo, [{ babelHelpers.createClass(Foo, [{
key: "test", key: "test",
value: function test() { value: function test() {
var _temp;
var _babelHelpers$classPr; var _babelHelpers$classPr;
var _foo2 = new WeakMap(); var _foo2 = new WeakMap();
@ -41,14 +39,14 @@ var Foo = /*#__PURE__*/function () {
} }
return Nested; return Nested;
}((_temp = (_babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _foo), /*#__PURE__*/function () { }((_babelHelpers$classPr = babelHelpers.classPrivateFieldGet(this, _foo), /*#__PURE__*/function () {
function _class2() { function _class2() {
babelHelpers.classCallCheck(this, _class2); babelHelpers.classCallCheck(this, _class2);
babelHelpers.defineProperty(this, _babelHelpers$classPr, 2); babelHelpers.defineProperty(this, _babelHelpers$classPr, 2);
} }
return _class2; return _class2;
}()), _temp)); }()));
} }
}]); }]);
return Foo; return Foo;

View File

@ -1,9 +1,7 @@
var createClass = k => { var createClass = k => {
var _temp;
var _k; var _k;
return _temp = (_k = k(), /*#__PURE__*/function () { return _k = k(), /*#__PURE__*/function () {
"use strict"; "use strict";
function _class2() { function _class2() {
@ -12,5 +10,5 @@ var createClass = k => {
} }
return _class2; return _class2;
}()), _temp; }();
}; };

View File

@ -1,10 +1,10 @@
let _Symbol$search; let _Symbol$search;
var _class, _descriptor, _temp; var _class, _descriptor;
function dec() {} function dec() {}
let A = (_class = (_temp = (_Symbol$search = Symbol.search, /*#__PURE__*/function () { let A = (_class = (_Symbol$search = Symbol.search, /*#__PURE__*/function () {
"use strict"; "use strict";
function A() { function A() {
@ -17,7 +17,7 @@ let A = (_class = (_temp = (_Symbol$search = Symbol.search, /*#__PURE__*/functio
value: function () {} value: function () {}
}]); }]);
return A; return A;
}()), _temp), (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], { }()), (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], {
configurable: true, configurable: true,
enumerable: true, enumerable: true,
writable: true, writable: true,

View File

@ -25,10 +25,10 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
}; }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue; babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue;
}; }

View File

@ -17,6 +17,6 @@ class Cl {
} }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue; babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue;
}; }

View File

@ -13,6 +13,6 @@ class Foo {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return 42; return 42;
}; }

View File

@ -18,6 +18,6 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
}; }

View File

@ -46,10 +46,10 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
}; }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue; babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue;
}; }

View File

@ -25,10 +25,10 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
}; }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue; babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue;
}; }

View File

@ -17,6 +17,6 @@ class Cl {
} }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue; babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue;
}; }

View File

@ -18,6 +18,6 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
}; }

View File

@ -46,10 +46,10 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
}; }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue; babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField] = newValue;
}; }

View File

@ -27,10 +27,10 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldGet(this, _privateField); return babelHelpers.classPrivateFieldGet(this, _privateField);
}; }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldSet(this, _privateField, newValue); babelHelpers.classPrivateFieldSet(this, _privateField, newValue);
}; }

View File

@ -19,6 +19,6 @@ class Cl {
} }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldSet(this, _privateField, newValue); babelHelpers.classPrivateFieldSet(this, _privateField, newValue);
}; }

View File

@ -19,6 +19,6 @@ class Foo {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return 42; return 42;
}; }

View File

@ -25,8 +25,8 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldGet(this, _privateField); return babelHelpers.classPrivateFieldGet(this, _privateField);
}; }
var cl = new Cl(); var cl = new Cl();

View File

@ -50,10 +50,10 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldGet(this, _privateField); return babelHelpers.classPrivateFieldGet(this, _privateField);
}; }
var _set_privateFieldValue = function (newValue) { function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldSet(this, _privateField, newValue); babelHelpers.classPrivateFieldSet(this, _privateField, newValue);
}; }

View File

@ -24,6 +24,6 @@ class Sub extends Base {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return Base.prototype.superMethod.call(this); return Base.prototype.superMethod.call(this);
}; }

View File

@ -17,10 +17,10 @@ class Cl {
} }
var _get_getSet = function () { function _get_getSet() {
return babelHelpers.classPrivateFieldGet(this, _privateField); return babelHelpers.classPrivateFieldGet(this, _privateField);
}; }
var _set_getSet = function (newValue) { function _set_getSet(newValue) {
babelHelpers.classPrivateFieldSet(this, _privateField, newValue); babelHelpers.classPrivateFieldSet(this, _privateField, newValue);
}; }

View File

@ -17,10 +17,10 @@ class Cl {
} }
var _set_getSet = function (newValue) { function _set_getSet(newValue) {
babelHelpers.classPrivateFieldSet(this, _privateField, newValue); babelHelpers.classPrivateFieldSet(this, _privateField, newValue);
}; }
var _get_getSet = function () { function _get_getSet() {
return babelHelpers.classPrivateFieldGet(this, _privateField); return babelHelpers.classPrivateFieldGet(this, _privateField);
}; }

View File

@ -10,6 +10,6 @@ class Foo {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return 42; return 42;
}; }

View File

@ -13,6 +13,6 @@ class Cl {
} }
var _foo2 = async function _foo2() { async function _foo2() {
return 2; return 2;
}; }

View File

@ -20,6 +20,6 @@ class Cl {
} }
var _method2 = function _method2(x) { function _method2(x) {
return x; return x;
}; }

View File

@ -0,0 +1,7 @@
console.log(class A {
#foo() {}
method() {
this.#foo();
}
});

View File

@ -0,0 +1,16 @@
var _foo;
console.log((_foo = babelHelpers.classPrivateFieldLooseKey("foo"), class A {
constructor() {
Object.defineProperty(this, _foo, {
value: _foo2
});
}
method() {
babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo]();
}
}));
function _foo2() {}

View File

@ -35,6 +35,6 @@ class Foo {
} }
var _getStatus2 = function _getStatus2() { function _getStatus2() {
return this.status; return this.status;
}; }

View File

@ -15,4 +15,4 @@ class Foo {
} }
var _privateMethod2 = function _privateMethod2() {}; function _privateMethod2() {}

View File

@ -13,7 +13,7 @@ class Cl {
} }
var _foo2 = function* _foo2() { function* _foo2() {
yield 2; yield 2;
return 3; return 3;
}; }

View File

@ -12,6 +12,6 @@ class Foo {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return 42; return 42;
}; }

View File

@ -25,6 +25,6 @@ class Sub extends Base {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return Base.prototype.superMethod.call(this); return Base.prototype.superMethod.call(this);
}; }

View File

@ -10,6 +10,6 @@ class Foo {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return 42; return 42;
}; }

View File

@ -13,6 +13,6 @@ class Cl {
} }
var _foo2 = async function _foo2() { async function _foo2() {
return 2; return 2;
}; }

View File

@ -20,6 +20,6 @@ class Cl {
} }
var _method2 = function _method2(x) { function _method2(x) {
return x; return x;
}; }

View File

@ -0,0 +1,7 @@
console.log(class A {
#foo() {}
method() {
this.#foo();
}
});

View File

@ -0,0 +1,16 @@
var _foo;
console.log((_foo = babelHelpers.classPrivateFieldLooseKey("foo"), class A {
constructor() {
Object.defineProperty(this, _foo, {
value: _foo2
});
}
method() {
babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo]();
}
}));
function _foo2() {}

View File

@ -35,6 +35,6 @@ class Foo {
} }
var _getStatus2 = function _getStatus2() { function _getStatus2() {
return this.status; return this.status;
}; }

View File

@ -15,4 +15,4 @@ class Foo {
} }
var _privateMethod2 = function _privateMethod2() {}; function _privateMethod2() {}

View File

@ -13,7 +13,7 @@ class Cl {
} }
var _foo2 = function* _foo2() { function* _foo2() {
yield 2; yield 2;
return 3; return 3;
}; }

View File

@ -25,6 +25,6 @@ class Sub extends Base {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return babelHelpers.get(babelHelpers.getPrototypeOf(Sub.prototype), "superMethod", this).call(this); return babelHelpers.get(babelHelpers.getPrototypeOf(Sub.prototype), "superMethod", this).call(this);
}; }

View File

@ -9,6 +9,6 @@ class Foo {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return 42; return 42;
}; }

View File

@ -11,6 +11,6 @@ class Cl {
} }
var _foo2 = async function _foo2() { async function _foo2() {
return 2; return 2;
}; }

View File

@ -20,6 +20,6 @@ class Cl {
} }
var _method2 = function _method2(x) { function _method2(x) {
return x; return x;
}; }

View File

@ -0,0 +1,7 @@
console.log(class A {
#foo() {}
method() {
this.#foo();
}
});

View File

@ -0,0 +1,14 @@
var _foo;
console.log((_foo = new WeakSet(), class A {
constructor() {
_foo.add(this);
}
method() {
babelHelpers.classPrivateMethodGet(this, _foo, _foo2).call(this);
}
}));
function _foo2() {}

View File

@ -33,6 +33,6 @@ class Foo {
} }
var _getStatus2 = function _getStatus2() { function _getStatus2() {
return this.status; return this.status;
}; }

View File

@ -13,4 +13,4 @@ class Foo {
} }
var _privateMethod2 = function _privateMethod2() {}; function _privateMethod2() {}

View File

@ -11,7 +11,7 @@ class Cl {
} }
var _foo2 = function* _foo2() { function* _foo2() {
yield 2; yield 2;
return 3; return 3;
}; }

View File

@ -16,4 +16,4 @@ class A {
} }
var _method2 = function _method2() {}; function _method2() {}

View File

@ -16,6 +16,6 @@ class Foo {
} }
var _privateFieldValue2 = function _privateFieldValue2() { function _privateFieldValue2() {
return 42; return 42;
}; }

View File

@ -24,6 +24,6 @@ class Sub extends Base {
} }
var _privateMethod2 = function _privateMethod2() { function _privateMethod2() {
return babelHelpers.get(babelHelpers.getPrototypeOf(Sub.prototype), "superMethod", this).call(this); return babelHelpers.get(babelHelpers.getPrototypeOf(Sub.prototype), "superMethod", this).call(this);
}; }

View File

@ -5,9 +5,9 @@ class Cl {
} }
var _privateStaticMethod = async function _privateStaticMethod() { async function _privateStaticMethod() {
return 2; return 2;
}; }
return new Cl().test().then(val => { return new Cl().test().then(val => {
expect(val).toBe(2); expect(val).toBe(2);

View File

@ -23,9 +23,9 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() { function _privateStaticMethod2() {
return 1017; return 1017;
}; }
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -7,7 +7,7 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() {}; function _privateStaticMethod2() {}
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -0,0 +1,7 @@
console.log(class A {
static #foo() {}
method() {
this.#foo();
}
});

View File

@ -0,0 +1,12 @@
var _class, _foo, _temp;
console.log((_temp = (_foo = babelHelpers.classPrivateFieldLooseKey("foo"), _class = class A {
method() {
babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo]();
}
}), Object.defineProperty(_class, _foo, {
value: _foo2
}), _temp));
function _foo2() {}

View File

@ -11,9 +11,9 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() { function _privateStaticMethod2() {
return 1017; return 1017;
}; }
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -7,10 +7,10 @@ class Cl {
} }
var _foo2 = function* _foo2() { function* _foo2() {
yield 2; yield 2;
return 3; return 3;
}; }
Object.defineProperty(Cl, _foo, { Object.defineProperty(Cl, _foo, {
value: _foo2 value: _foo2

View File

@ -7,7 +7,7 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() {}; function _privateStaticMethod2() {}
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -18,9 +18,9 @@ class Sub extends Base {
} }
var _subStaticPrivateMethod2 = function _subStaticPrivateMethod2() { function _subStaticPrivateMethod2() {
return Base.basePublicStaticMethod.call(this); return Base.basePublicStaticMethod.call(this);
}; }
Object.defineProperty(Sub, _subStaticPrivateMethod, { Object.defineProperty(Sub, _subStaticPrivateMethod, {
value: _subStaticPrivateMethod2 value: _subStaticPrivateMethod2

View File

@ -20,18 +20,17 @@ class B extends A {
} }
var _getB2 = function _getB2() { function _getA2() {
return A.a;
}
function _getB2() {
return this.b; return this.b;
}; }
Object.defineProperty(B, _getB, { Object.defineProperty(B, _getB, {
value: _getB2 value: _getB2
}); });
var _getA2 = function _getA2() {
return A.a;
};
Object.defineProperty(B, _getA, { Object.defineProperty(B, _getA, {
value: _getA2 value: _getA2
}); });

View File

@ -7,9 +7,9 @@ class Cl {
} }
var _privateStaticMethod2 = async function _privateStaticMethod2() { async function _privateStaticMethod2() {
return 2; return 2;
}; }
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -23,9 +23,9 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() { function _privateStaticMethod2() {
return 1017; return 1017;
}; }
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -7,7 +7,7 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() {}; function _privateStaticMethod2() {}
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -0,0 +1,7 @@
console.log(class A {
static #foo() {}
method() {
this.#foo();
}
});

View File

@ -0,0 +1,12 @@
var _class, _foo, _temp;
console.log((_temp = (_foo = babelHelpers.classPrivateFieldLooseKey("foo"), _class = class A {
method() {
babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo]();
}
}), Object.defineProperty(_class, _foo, {
value: _foo2
}), _temp));
function _foo2() {}

View File

@ -11,9 +11,9 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() { function _privateStaticMethod2() {
return 1017; return 1017;
}; }
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -7,10 +7,10 @@ class Cl {
} }
var _foo2 = function* _foo2() { function* _foo2() {
yield 2; yield 2;
return 3; return 3;
}; }
Object.defineProperty(Cl, _foo, { Object.defineProperty(Cl, _foo, {
value: _foo2 value: _foo2

View File

@ -7,7 +7,7 @@ class Cl {
} }
var _privateStaticMethod2 = function _privateStaticMethod2() {}; function _privateStaticMethod2() {}
Object.defineProperty(Cl, _privateStaticMethod, { Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2 value: _privateStaticMethod2

View File

@ -18,9 +18,9 @@ class Sub extends Base {
} }
var _subStaticPrivateMethod2 = function _subStaticPrivateMethod2() { function _subStaticPrivateMethod2() {
return babelHelpers.get(babelHelpers.getPrototypeOf(Sub), "basePublicStaticMethod", this).call(this); return babelHelpers.get(babelHelpers.getPrototypeOf(Sub), "basePublicStaticMethod", this).call(this);
}; }
Object.defineProperty(Sub, _subStaticPrivateMethod, { Object.defineProperty(Sub, _subStaticPrivateMethod, {
value: _subStaticPrivateMethod2 value: _subStaticPrivateMethod2

View File

@ -20,18 +20,17 @@ class B extends A {
} }
var _getB2 = function _getB2() { function _getA2() {
return babelHelpers.get(babelHelpers.getPrototypeOf(B), "a", this);
}
function _getB2() {
return this.b; return this.b;
}; }
Object.defineProperty(B, _getB, { Object.defineProperty(B, _getB, {
value: _getB2 value: _getB2
}); });
var _getA2 = function _getA2() {
return babelHelpers.get(babelHelpers.getPrototypeOf(B), "a", this);
};
Object.defineProperty(B, _getA, { Object.defineProperty(B, _getA, {
value: _getA2 value: _getA2
}); });

View File

@ -5,9 +5,9 @@ class Cl {
} }
var _privateStaticMethod = async function _privateStaticMethod() { async function _privateStaticMethod() {
return 2; return 2;
}; }
return new Cl().test().then(val => { return new Cl().test().then(val => {
expect(val).toBe(2); expect(val).toBe(2);

View File

@ -21,6 +21,6 @@ class Cl {
} }
var _privateStaticMethod = function _privateStaticMethod() { function _privateStaticMethod() {
return 1017; return 1017;
}; }

View File

@ -5,4 +5,4 @@ class Cl {
} }
var _privateStaticMethod = function _privateStaticMethod() {}; function _privateStaticMethod() {}

View File

@ -0,0 +1,7 @@
console.log(class A {
static #foo() {}
method() {
this.#foo();
}
});

View File

@ -0,0 +1,10 @@
var _class;
console.log(_class = class A {
method() {
babelHelpers.classStaticPrivateMethodGet(this, _class, _foo).call(this);
}
});
function _foo() {}

View File

@ -9,6 +9,6 @@ class Cl {
} }
var _privateStaticMethod = function _privateStaticMethod() { function _privateStaticMethod() {
return 1017; return 1017;
}; }

View File

@ -5,7 +5,7 @@ class Cl {
} }
var _foo = function* _foo() { function* _foo() {
yield 2; yield 2;
return 3; return 3;
}; }

View File

@ -6,4 +6,4 @@ class A {
} }
var _method = function _method() {}; function _method() {}

View File

@ -16,6 +16,6 @@ class Sub extends Base {
} }
var _subStaticPrivateMethod = function _subStaticPrivateMethod() { function _subStaticPrivateMethod() {
return babelHelpers.get(babelHelpers.getPrototypeOf(Sub), "basePublicStaticMethod", this).call(this); return babelHelpers.get(babelHelpers.getPrototypeOf(Sub), "basePublicStaticMethod", this).call(this);
}; }

View File

@ -16,12 +16,12 @@ class B extends A {
} }
var _getB = function _getB() { function _getA() {
return this.b;
};
var _getA = function _getA() {
return babelHelpers.get(babelHelpers.getPrototypeOf(B), "a", this); return babelHelpers.get(babelHelpers.getPrototypeOf(B), "a", this);
}; }
function _getB() {
return this.b;
}
var [getA, getB] = B.extract(); var [getA, getB] = B.extract();

View File

@ -13,13 +13,13 @@ class Cl {
} }
var _set_privateStaticFieldValue = function (newValue) { function _get_privateStaticFieldValue() {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = `Updated: ${newValue}`;
};
var _get_privateStaticFieldValue = function () {
return babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD]; return babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD];
}; }
function _set_privateStaticFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = `Updated: ${newValue}`;
}
Object.defineProperty(Cl, _privateStaticFieldValue, { Object.defineProperty(Cl, _privateStaticFieldValue, {
get: _get_privateStaticFieldValue, get: _get_privateStaticFieldValue,

View File

@ -9,9 +9,9 @@ class C {
} }
var _set_p = function (v) { function _set_p(v) {
babelHelpers.classPrivateFieldLooseBase(C, _q)[_q] = v; babelHelpers.classPrivateFieldLooseBase(C, _q)[_q] = v;
}; }
Object.defineProperty(C, _p, { Object.defineProperty(C, _p, {
get: void 0, get: void 0,

View File

@ -9,9 +9,9 @@ class Cl {
} }
var _set_privateStaticFieldValue = function (newValue) { function _set_privateStaticFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = newValue; babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = newValue;
}; }
Object.defineProperty(Cl, _privateStaticFieldValue, { Object.defineProperty(Cl, _privateStaticFieldValue, {
get: void 0, get: void 0,

View File

@ -10,9 +10,9 @@ class Cl {
} }
var _get_privateFieldValue = function () { function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
}; }
Object.defineProperty(Cl, _privateFieldValue, { Object.defineProperty(Cl, _privateFieldValue, {
get: _get_privateFieldValue, get: _get_privateFieldValue,

View File

@ -34,13 +34,13 @@ class Cl {
} }
var _set_privateFieldValue = function (newValue) { function _get_privateFieldValue() {
babelHelpers.classPrivateFieldLooseBase(Cl, _privateField)[_privateField] = newValue;
};
var _get_privateFieldValue = function () {
return babelHelpers.classPrivateFieldLooseBase(Cl, _privateField)[_privateField]; return babelHelpers.classPrivateFieldLooseBase(Cl, _privateField)[_privateField];
}; }
function _set_privateFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(Cl, _privateField)[_privateField] = newValue;
}
Object.defineProperty(Cl, _privateFieldValue, { Object.defineProperty(Cl, _privateFieldValue, {
get: _get_privateFieldValue, get: _get_privateFieldValue,

View File

@ -13,13 +13,13 @@ class Cl {
} }
var _set_privateStaticFieldValue = function (newValue) { function _get_privateStaticFieldValue() {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = `Updated: ${newValue}`;
};
var _get_privateStaticFieldValue = function () {
return babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD]; return babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD];
}; }
function _set_privateStaticFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = `Updated: ${newValue}`;
}
Object.defineProperty(Cl, _privateStaticFieldValue, { Object.defineProperty(Cl, _privateStaticFieldValue, {
get: _get_privateStaticFieldValue, get: _get_privateStaticFieldValue,

View File

@ -9,9 +9,9 @@ class C {
} }
var _set_p = function (v) { function _set_p(v) {
babelHelpers.classPrivateFieldLooseBase(C, _q)[_q] = v; babelHelpers.classPrivateFieldLooseBase(C, _q)[_q] = v;
}; }
Object.defineProperty(C, _p, { Object.defineProperty(C, _p, {
get: void 0, get: void 0,

View File

@ -9,9 +9,9 @@ class Cl {
} }
var _set_privateStaticFieldValue = function (newValue) { function _set_privateStaticFieldValue(newValue) {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = newValue; babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = newValue;
}; }
Object.defineProperty(Cl, _privateStaticFieldValue, { Object.defineProperty(Cl, _privateStaticFieldValue, {
get: void 0, get: void 0,

Some files were not shown because too many files have changed in this diff Show More