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

View File

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

View File

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

View File

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

View File

@ -9,8 +9,8 @@ class A extends B {
}
var _foo2 = function _foo2() {
function _foo2() {
let _A;
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;
return babelHelpers.wrapAsyncGenerator(function* () {
@ -16,4 +16,4 @@ var _g2 = function _g2() {
yield 2;
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 _defineProperty() {}
let A = (_class = (_temp = function A() {
let A = (_class = function A() {
"use strict";
babelHelpers.classCallCheck(this, A);
babelHelpers.initializerDefineProperty(this, "a", _descriptor, this);
babelHelpers.initializerDefineProperty(this, "b", _descriptor2, this);
babelHelpers.defineProperty(this, "c", 456);
}, _temp), (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], {
}, (_descriptor = babelHelpers.applyDecoratedDescriptor(_class.prototype, "a", [dec], {
configurable: true,
enumerable: true,
writable: true,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,10 +25,10 @@ class Cl {
}
var _get_privateFieldValue = function () {
function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldLooseBase(this, _privateField)[_privateField];
};
}
var _set_privateFieldValue = function (newValue) {
function _set_privateFieldValue(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;
};
}

View File

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

View File

@ -18,6 +18,6 @@ class Cl {
}
var _get_privateFieldValue = function () {
function _get_privateFieldValue() {
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];
};
}
var _set_privateFieldValue = function (newValue) {
function _set_privateFieldValue(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];
};
}
var _set_privateFieldValue = function (newValue) {
function _set_privateFieldValue(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;
};
}

View File

@ -18,6 +18,6 @@ class Cl {
}
var _get_privateFieldValue = function () {
function _get_privateFieldValue() {
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];
};
}
var _set_privateFieldValue = function (newValue) {
function _set_privateFieldValue(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);
};
}
var _set_privateFieldValue = function (newValue) {
function _set_privateFieldValue(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);
};
}

View File

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

View File

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

View File

@ -50,10 +50,10 @@ class Cl {
}
var _get_privateFieldValue = function () {
function _get_privateFieldValue() {
return babelHelpers.classPrivateFieldGet(this, _privateField);
};
}
var _set_privateFieldValue = function (newValue) {
function _set_privateFieldValue(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);
};
}

View File

@ -17,10 +17,10 @@ class Cl {
}
var _get_getSet = function () {
function _get_getSet() {
return babelHelpers.classPrivateFieldGet(this, _privateField);
};
}
var _set_getSet = function (newValue) {
function _set_getSet(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);
};
}
var _get_getSet = function () {
function _get_getSet() {
return babelHelpers.classPrivateFieldGet(this, _privateField);
};
}

View File

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

View File

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

View File

@ -20,6 +20,6 @@ class Cl {
}
var _method2 = function _method2(x) {
function _method2(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;
};
}

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;
return 3;
};
}

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,6 @@ class Cl {
}
var _method2 = function _method2(x) {
function _method2(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;
};
}

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

View File

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

View File

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

View File

@ -20,6 +20,6 @@ class Cl {
}
var _method2 = function _method2(x) {
function _method2(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;
};
}

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

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

View File

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

View File

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

View File

@ -7,7 +7,7 @@ class Cl {
}
var _privateStaticMethod2 = function _privateStaticMethod2() {};
function _privateStaticMethod2() {}
Object.defineProperty(Cl, _privateStaticMethod, {
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;
};
}
Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2

View File

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

View File

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

View File

@ -18,9 +18,9 @@ class Sub extends Base {
}
var _subStaticPrivateMethod2 = function _subStaticPrivateMethod2() {
function _subStaticPrivateMethod2() {
return Base.basePublicStaticMethod.call(this);
};
}
Object.defineProperty(Sub, _subStaticPrivateMethod, {
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;
};
}
Object.defineProperty(B, _getB, {
value: _getB2
});
var _getA2 = function _getA2() {
return A.a;
};
Object.defineProperty(B, _getA, {
value: _getA2
});

View File

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

View File

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

View File

@ -7,7 +7,7 @@ class Cl {
}
var _privateStaticMethod2 = function _privateStaticMethod2() {};
function _privateStaticMethod2() {}
Object.defineProperty(Cl, _privateStaticMethod, {
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;
};
}
Object.defineProperty(Cl, _privateStaticMethod, {
value: _privateStaticMethod2

View File

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

View File

@ -7,7 +7,7 @@ class Cl {
}
var _privateStaticMethod2 = function _privateStaticMethod2() {};
function _privateStaticMethod2() {}
Object.defineProperty(Cl, _privateStaticMethod, {
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);
};
}
Object.defineProperty(Sub, _subStaticPrivateMethod, {
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;
};
}
Object.defineProperty(B, _getB, {
value: _getB2
});
var _getA2 = function _getA2() {
return babelHelpers.get(babelHelpers.getPrototypeOf(B), "a", this);
};
Object.defineProperty(B, _getA, {
value: _getA2
});

View File

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

View File

@ -21,6 +21,6 @@ class Cl {
}
var _privateStaticMethod = function _privateStaticMethod() {
function _privateStaticMethod() {
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;
};
}

View File

@ -5,7 +5,7 @@ class Cl {
}
var _foo = function* _foo() {
function* _foo() {
yield 2;
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);
};
}

View File

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

View File

@ -13,13 +13,13 @@ class Cl {
}
var _set_privateStaticFieldValue = function (newValue) {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = `Updated: ${newValue}`;
};
var _get_privateStaticFieldValue = function () {
function _get_privateStaticFieldValue() {
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, {
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;
};
}
Object.defineProperty(C, _p, {
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;
};
}
Object.defineProperty(Cl, _privateStaticFieldValue, {
get: void 0,

View File

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

View File

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

View File

@ -13,13 +13,13 @@ class Cl {
}
var _set_privateStaticFieldValue = function (newValue) {
babelHelpers.classPrivateFieldLooseBase(Cl, _PRIVATE_STATIC_FIELD)[_PRIVATE_STATIC_FIELD] = `Updated: ${newValue}`;
};
var _get_privateStaticFieldValue = function () {
function _get_privateStaticFieldValue() {
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, {
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;
};
}
Object.defineProperty(C, _p, {
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;
};
}
Object.defineProperty(Cl, _privateStaticFieldValue, {
get: void 0,

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