diff --git a/packages/babel-helper-create-class-features-plugin/src/decorators.ts b/packages/babel-helper-create-class-features-plugin/src/decorators.ts index 240f85f213c2..5495a09d7d59 100644 --- a/packages/babel-helper-create-class-features-plugin/src/decorators.ts +++ b/packages/babel-helper-create-class-features-plugin/src/decorators.ts @@ -182,10 +182,9 @@ function addProxyAccessorsFor( originalKey: t.PrivateName | t.Expression, targetKey: t.PrivateName, version: DecoratorVersionKind, - isComputed = false, + isComputed: boolean, + isStatic: boolean, ): void { - const { static: isStatic } = element.node; - const thisArg = (version === "2023-11" || (!process.env.BABEL_8_BREAKING && version === "2023-05")) && @@ -610,6 +609,7 @@ function addCallAccessorsFor( key: t.PrivateName, getId: t.Identifier, setId: t.Identifier, + isStatic: boolean, ) { element.insertAfter( t.classPrivateMethod( @@ -621,6 +621,7 @@ function addCallAccessorsFor( t.callExpression(t.cloneNode(getId), [t.thisExpression()]), ), ]), + isStatic, ), ); @@ -637,6 +638,7 @@ function addCallAccessorsFor( ]), ), ]), + isStatic, ), ); } @@ -885,6 +887,7 @@ function transformClass( newId, version, computed, + isStatic, ); } } @@ -1099,7 +1102,7 @@ function transformClass( `set_${name}`, ); - addCallAccessorsFor(newPath, key, getId, setId); + addCallAccessorsFor(newPath, key, getId, setId, isStatic); locals = [newFieldInitId, getId, setId]; } else { @@ -1110,6 +1113,7 @@ function transformClass( newId, version, isComputed, + isStatic, ); locals = [newFieldInitId]; } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/output.js index 0205d9da263a..94a0eda4ef78 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/context-name/output.js @@ -10,14 +10,7 @@ const f = () => { }; }; _computedKey = babelHelpers.toPropertyKey(f()); -var _a = /*#__PURE__*/new WeakMap(); class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } static get a() { return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _A); } @@ -74,6 +67,10 @@ function _set_a2(v) { function _get_a2() { return _get_a(this); } +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs(_Foo, [[dec, 6, "a"], [dec, 6, "a", function () { return babelHelpers.classStaticPrivateFieldSpecGet(this, _Foo, _B); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/static-private/output.js index e0ff30ad9684..e499d60397bd 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors--to-es2015/static-private/output.js @@ -1,19 +1,6 @@ var _initStatic, _init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _Foo; const dec = () => {}; -var _a = /*#__PURE__*/new WeakMap(); -var _b = /*#__PURE__*/new WeakMap(); -class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _b, { - get: _get_b2, - set: _set_b2 - }); - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } -} +class Foo {} _Foo = Foo; function _set_a2(v) { _set_a(this, v); @@ -27,6 +14,14 @@ function _set_b2(v) { function _get_b2() { return _get_b(this); } +var _b = { + get: _get_b2, + set: _set_b2 +}; +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic] = babelHelpers.applyDecs(_Foo, [[dec, 6, "a", function () { return babelHelpers.classStaticPrivateFieldSpecGet(this, _Foo, _A); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/output.js index a65ab7f7abdf..6f69deb83763 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/context-name/output.js @@ -27,10 +27,10 @@ class Foo { this.#A = v; } static #B = _init_a2(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #C = _init_computedKey(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/static-private/output.js index bc9c9fc3a04c..c9cc5d0d9caf 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-accessors/static-private/output.js @@ -14,17 +14,17 @@ class Foo { _initStatic(this); } static #A = _init_a(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #B = _init_b(this, 123); - set #b(v) { + static set #b(v) { _set_b(this, v); } - get #b() { + static get #b() { return _get_b(this); } } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-misc/all-decorators/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-misc/all-decorators/output.js index 0d698d3134b5..109320ec4a1b 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-misc/all-decorators/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2021-12-misc/all-decorators/output.js @@ -59,12 +59,6 @@ new class extends babelHelpers.identity { static set m(v) { this.#C = v; } - set #r(v) { - _set_r(this, v); - } - get #r() { - return _get_r(this); - } } } #o = _call_o; @@ -78,6 +72,12 @@ new class extends babelHelpers.identity { _call_q(this, v); } #D = _init_r(this); + set #r(v) { + _set_r(this, v); + } + get #r() { + return _get_r(this); + } constructor() { super(_Class), _initClass(); } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/output.js index 8ea053f262c9..5ecb54f2249e 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/context-name/output.js @@ -10,14 +10,7 @@ const f = () => { }; }; _computedKey = babelHelpers.toPropertyKey(f()); -var _a = /*#__PURE__*/new WeakMap(); class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } static get a() { return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _A); } @@ -74,6 +67,10 @@ function _set_a2(v) { function _get_a2() { return _get_a(this); } +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2203R(_Foo, [[dec, 6, "a"], [dec, 6, "a", function () { return babelHelpers.classStaticPrivateFieldSpecGet(this, _Foo, _B); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/static-private/output.js index d5184806b8fe..0661a48f2a7a 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors--to-es2015/static-private/output.js @@ -1,19 +1,6 @@ var _initStatic, _init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _Foo; const dec = () => {}; -var _a = /*#__PURE__*/new WeakMap(); -var _b = /*#__PURE__*/new WeakMap(); -class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _b, { - get: _get_b2, - set: _set_b2 - }); - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } -} +class Foo {} _Foo = Foo; function _set_a2(v) { _set_a(this, v); @@ -27,6 +14,14 @@ function _set_b2(v) { function _get_b2() { return _get_b(this); } +var _b = { + get: _get_b2, + set: _set_b2 +}; +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic] = babelHelpers.applyDecs2203R(_Foo, [[dec, 6, "a", function () { return babelHelpers.classStaticPrivateFieldSpecGet(this, _Foo, _A); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/output.js index 4a73466f5a03..b8eb29a26438 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/context-name/output.js @@ -27,10 +27,10 @@ class Foo { this.#A = v; } static #B = _init_a2(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #C = _init_computedKey(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/static-private/output.js index 75fe2d38b6eb..080419954303 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-accessors/static-private/output.js @@ -14,17 +14,17 @@ class Foo { _initStatic(this); } static #A = _init_a(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #B = _init_b(this, 123); - set #b(v) { + static set #b(v) { _set_b(this, v); } - get #b() { + static get #b() { return _get_b(this); } } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-misc/all-decorators/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-misc/all-decorators/output.js index 8326a01677e1..d8da8cfefca1 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-misc/all-decorators/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2022-03-misc/all-decorators/output.js @@ -62,12 +62,6 @@ new class extends babelHelpers.identity { static set m(v) { this.#C = v; } - set #r(v) { - _set_r(this, v); - } - get #r() { - return _get_r(this); - } } } #o = _call_o; @@ -81,6 +75,12 @@ new class extends babelHelpers.identity { _call_q(this, v); } #D = _init_r(this); + set #r(v) { + _set_r(this, v); + } + get #r() { + return _get_r(this); + } constructor() { super(_Class), _initClass(); } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/output.js index bcc76b2e2e0f..43ac156963be 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/context-name/output.js @@ -10,14 +10,7 @@ const f = () => { }; }; _computedKey = babelHelpers.toPropertyKey(f()); -var _a = /*#__PURE__*/new WeakMap(); class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } static get a() { return babelHelpers.classStaticPrivateFieldSpecGet(this, Foo, _A); } @@ -74,6 +67,10 @@ function _set_a2(v) { function _get_a2() { return _get_a(this); } +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2301(_Foo, [[dec, 6, "a"], [dec, 6, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _B, v)], [dec, 6, "b"], [dec, 6, "c"], [dec, 6, 0], [dec, 6, 1], [dec, 6, 2n], [dec, 6, 3n], [dec, 6, _computedKey]], []).e; _initStatic(_Foo); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js index a32daa9f49a0..b9ee5325bf68 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors--to-es2015/static-private/output.js @@ -1,19 +1,6 @@ var _initStatic, _init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _Foo; const dec = () => {}; -var _a = /*#__PURE__*/new WeakMap(); -var _b = /*#__PURE__*/new WeakMap(); -class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _b, { - get: _get_b2, - set: _set_b2 - }); - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } -} +class Foo {} _Foo = Foo; function _set_a2(v) { _set_a(this, v); @@ -27,6 +14,14 @@ function _set_b2(v) { function _get_b2() { return _get_b(this); } +var _b = { + get: _get_b2, + set: _set_b2 +}; +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic] = babelHelpers.applyDecs2301(_Foo, [[dec, 6, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _A), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _A, v)], [dec, 6, "b", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _B, v)]], []).e; _initStatic(_Foo); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/output.js index c75be1905b9e..37a924ceddd5 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/context-name/output.js @@ -23,10 +23,10 @@ class Foo { this.#A = v; } static #B = _init_a2(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #C = _init_computedKey(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js index a5fe087f6933..e215d1f3016d 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-accessors/static-private/output.js @@ -6,17 +6,17 @@ class Foo { _initStatic(this); } static #A = _init_a(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #B = _init_b(this, 123); - set #b(v) { + static set #b(v) { _set_b(this, v); } - get #b() { + static get #b() { return _get_b(this); } } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js index f948341b9a9a..c35c68ccaa54 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-01-misc/all-decorators/output.js @@ -46,12 +46,6 @@ new class extends babelHelpers.identity { static set m(v) { this.#C = v; } - set #r(v) { - _set_r(this, v); - } - get #r() { - return _get_r(this); - } } } #o = _call_o; @@ -65,6 +59,12 @@ new class extends babelHelpers.identity { _call_q(this, v); } #D = _init_r(this); + set #r(v) { + _set_r(this, v); + } + get #r() { + return _get_r(this); + } constructor() { super(_Class), _initClass(); } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/output.js index 34dae25505be..48ad86b81e6f 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/context-name/output.js @@ -10,14 +10,7 @@ const f = () => { }; }; _computedKey = babelHelpers.toPropertyKey(f()); -var _a = /*#__PURE__*/new WeakMap(); class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } static get a() { return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _A); } @@ -74,6 +67,10 @@ function _set_a2(v) { function _get_a2() { return _get_a(this); } +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _init_a2, _get_a, _set_a, _init_computedKey, _init_computedKey2, _init_computedKey3, _init_computedKey4, _init_computedKey5, _init_computedKey6, _init_computedKey7, _initStatic] = babelHelpers.applyDecs2305(_Foo, [[dec, 9, "a"], [dec, 9, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _B, v)], [dec, 9, "b"], [dec, 9, "c"], [dec, 9, 0], [dec, 9, 1], [dec, 9, 2n], [dec, 9, 3n], [dec, 9, _computedKey]], []).e; _initStatic(_Foo); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/static-private/output.js index e894c227be2e..563d83d24b30 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors--to-es2015/static-private/output.js @@ -1,19 +1,6 @@ var _initStatic, _init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _Foo; const dec = () => {}; -var _a = /*#__PURE__*/new WeakMap(); -var _b = /*#__PURE__*/new WeakMap(); -class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _b, { - get: _get_b2, - set: _set_b2 - }); - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } -} +class Foo {} _Foo = Foo; function _set_a2(v) { _set_a(this, v); @@ -27,6 +14,14 @@ function _set_b2(v) { function _get_b2() { return _get_b(this); } +var _b = { + get: _get_b2, + set: _set_b2 +}; +var _a = { + get: _get_a2, + set: _set_a2 +}; (() => { [_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic] = babelHelpers.applyDecs2305(_Foo, [[dec, 9, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _A), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _A, v)], [dec, 9, "b", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _B, v)]], []).e; _initStatic(_Foo); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/output.js index dc9b9e1014ef..f430ae1bb369 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/context-name/output.js @@ -23,10 +23,10 @@ class Foo { Foo.#A = v; } static #B = _init_a2(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #C = _init_computedKey(this); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/static-private/output.js index 7a55991dbbf9..afc070cbc07c 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-accessors/static-private/output.js @@ -6,17 +6,17 @@ class Foo { _initStatic(this); } static #A = _init_a(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #B = _init_b(this, 123); - set #b(v) { + static set #b(v) { _set_b(this, v); } - get #b() { + static get #b() { return _get_b(this); } } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-misc/all-decorators/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-misc/all-decorators/output.js index 95d771a1ff4e..8ca7a3bf1bb0 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-misc/all-decorators/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-05-misc/all-decorators/output.js @@ -46,12 +46,6 @@ new class extends babelHelpers.identity { static set m(v) { Class.#C = v; } - set #r(v) { - _set_r(this, v); - } - get #r() { - return _get_r(this); - } } } #o = _call_o; @@ -65,6 +59,12 @@ new class extends babelHelpers.identity { _call_q(this, v); } #D = _init_r(this); + set #r(v) { + _set_r(this, v); + } + get #r() { + return _get_r(this); + } constructor() { super(_Class), _initClass(); } diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/context-name/output.js index 7e8772b02400..5c56253fa682 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/context-name/output.js @@ -10,14 +10,7 @@ const f = () => { }; }; _computedKey = babelHelpers.toPropertyKey(f()); -var _a = /*#__PURE__*/new WeakMap(); class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } static get a() { return babelHelpers.classStaticPrivateFieldSpecGet(Foo, Foo, _A); } @@ -74,6 +67,10 @@ function _set_a2(v) { function _get_a2() { return _get_a(this); } +var _a = { + get: _get_a2, + set: _set_a2 +}; [_init_a, _init_extra_a, _init_a2, _get_a, _set_a, _init_extra_a2, _init_computedKey, _init_extra_computedKey, _init_computedKey2, _init_extra_computedKey2, _init_computedKey3, _init_extra_computedKey3, _init_computedKey4, _init_extra_computedKey4, _init_computedKey5, _init_extra_computedKey5, _init_computedKey6, _init_extra_computedKey6, _init_computedKey7, _init_extra_computedKey7] = babelHelpers.applyDecs2311(_Foo, [[dec, 9, "a"], [dec, 9, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _B, v)], [dec, 9, "b"], [dec, 9, "c"], [dec, 9, 0], [dec, 9, 1], [dec, 9, 2n], [dec, 9, 3n], [dec, 9, _computedKey]], []).e; var _A = { writable: true, diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/static-private/output.js index 39c0fb8c80dc..ed7cc73c732a 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors--to-es2015/static-private/output.js @@ -1,19 +1,6 @@ var _init_a, _get_a, _set_a, _init_extra_a, _init_b, _get_b, _set_b, _init_extra_b, _Foo; const dec = () => {}; -var _a = /*#__PURE__*/new WeakMap(); -var _b = /*#__PURE__*/new WeakMap(); -class Foo { - constructor() { - babelHelpers.classPrivateFieldInitSpec(this, _b, { - get: _get_b2, - set: _set_b2 - }); - babelHelpers.classPrivateFieldInitSpec(this, _a, { - get: _get_a2, - set: _set_a2 - }); - } -} +class Foo {} _Foo = Foo; function _set_a2(v) { _set_a(this, v); @@ -27,6 +14,14 @@ function _set_b2(v) { function _get_b2() { return _get_b(this); } +var _b = { + get: _get_b2, + set: _set_b2 +}; +var _a = { + get: _get_a2, + set: _set_a2 +}; [_init_a, _get_a, _set_a, _init_extra_a, _init_b, _get_b, _set_b, _init_extra_b] = babelHelpers.applyDecs2311(_Foo, [[dec, 9, "a", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _A), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _A, v)], [dec, 9, "b", o => babelHelpers.classStaticPrivateFieldSpecGet(o, _Foo, _B), (o, v) => babelHelpers.classStaticPrivateFieldSpecSet(o, _Foo, _B, v)]], []).e; var _A = { writable: true, diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/context-name/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/context-name/output.js index 57825aeae112..b3dda8fda8e3 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/context-name/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/context-name/output.js @@ -22,10 +22,10 @@ class Foo { Foo.#A = v; } static #B = (_init_extra_a(this), _init_a2(this)); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #C = (_init_extra_a2(this), _init_computedKey(this)); diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/static-private/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/static-private/output.js index 76e957548f63..ff0b7b609ee7 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/static-private/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-accessors/static-private/output.js @@ -5,17 +5,17 @@ class Foo { [_init_a, _get_a, _set_a, _init_extra_a, _init_b, _get_b, _set_b, _init_extra_b] = babelHelpers.applyDecs2311(this, [[dec, 9, "a", o => o.#A, (o, v) => o.#A = v], [dec, 9, "b", o => o.#B, (o, v) => o.#B = v]], []).e; } static #A = _init_a(this); - set #a(v) { + static set #a(v) { _set_a(this, v); } - get #a() { + static get #a() { return _get_a(this); } static #B = (_init_extra_a(this), _init_b(this, 123)); - set #b(v) { + static set #b(v) { _set_b(this, v); } - get #b() { + static get #b() { return _get_b(this); } static { diff --git a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-misc/all-decorators/output.js b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-misc/all-decorators/output.js index 173d1770491b..11979c8bd966 100644 --- a/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-misc/all-decorators/output.js +++ b/packages/babel-plugin-proposal-decorators/test/fixtures/2023-11-misc/all-decorators/output.js @@ -49,12 +49,6 @@ new class extends babelHelpers.identity { static set m(v) { Class.#C = v; } - set #r(v) { - _set_r(this, v); - } - get #r() { - return _get_r(this); - } } } #o = _call_o; @@ -68,6 +62,12 @@ new class extends babelHelpers.identity { _call_q(this, v); } #D = (_init_extra_n(this), _init_r(this)); + set #r(v) { + _set_r(this, v); + } + get #r() { + return _get_r(this); + } constructor() { super(_Class), (() => { _init_extra_r(this);