Skip to content

Commit

Permalink
Rename to 2023-05
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed May 17, 2023
1 parent 9f42791 commit 83ae4d2
Show file tree
Hide file tree
Showing 367 changed files with 276 additions and 276 deletions.
4 changes: 2 additions & 2 deletions packages/babel-helpers/src/helpers-generated.ts

Large diffs are not rendered by default.

Expand Up @@ -664,7 +664,7 @@ function applyClassDecs(targetClass, classDecs, decoratorsHaveThis) {
initializeClass(Class);
*/

export default function applyDecs2303(
export default function applyDecs2305(
targetClass,
memberDecs,
classDecs,
Expand Down
6 changes: 3 additions & 3 deletions packages/babel-plugin-proposal-decorators/src/index.ts
Expand Up @@ -7,7 +7,7 @@ import {
FEATURES,
} from "@babel/helper-create-class-features-plugin";
import legacyVisitor from "./transformer-legacy";
import transformer2022_03 from "./transformer-2023-03";
import transformer2023_05 from "./transformer-2023-05";
import type { Options as SyntaxOptions } from "@babel/plugin-syntax-decorators";

interface Options extends SyntaxOptions {
Expand Down Expand Up @@ -41,9 +41,9 @@ export default declare((api, options: Options) => {
version === "2021-12" ||
version === "2022-03" ||
version === "2023-01" ||
version === "2023-03"
version === "2023-05"
) {
return transformer2022_03(api, options, version);
return transformer2023_05(api, options, version);
} else if (!process.env.BABEL_8_BREAKING) {
api.assertVersion("^7.0.2");
return createClassFeaturePlugin({
Expand Down
Expand Up @@ -20,7 +20,7 @@ type ClassElement =
| t.TSIndexSignature
| t.StaticBlock;

type DecoratorVersionKind = "2023-03" | "2023-01" | "2022-03" | "2021-12";
type DecoratorVersionKind = "2023-05" | "2023-01" | "2022-03" | "2021-12";

function incrementId(id: number[], idx = id.length - 1): void {
// If index is -1, id needs an additional character, unshift A
Expand Down Expand Up @@ -175,7 +175,7 @@ function addProxyAccessorsFor(
const { static: isStatic } = element.node;

const thisArg =
version === "2023-03" && isStatic ? className : t.thisExpression();
version === "2023-05" && isStatic ? className : t.thisExpression();

const getterBody = t.blockStatement([
t.returnStatement(
Expand Down Expand Up @@ -238,7 +238,7 @@ function extractProxyAccessorsFor(
targetKey: t.PrivateName,
version: DecoratorVersionKind,
): (t.FunctionExpression | t.ArrowFunctionExpression)[] {
if (version !== "2023-03" && version !== "2023-01") {
if (version !== "2023-05" && version !== "2023-01") {
return [
template.expression.ast`
function () {
Expand Down Expand Up @@ -269,7 +269,7 @@ const METHOD = 2;
const GETTER = 3;
const SETTER = 4;

const STATIC_OLD_VERSION = 5; // Before 2023-03
const STATIC_OLD_VERSION = 5; // Before 2023-05
const STATIC = 8; // 1 << 3
const DECORATORS_HAVE_THIS = 16; // 1 << 3

Expand Down Expand Up @@ -355,7 +355,7 @@ function generateDecorationList(
const hasOneThis = decoratorsThis.some(Boolean);
const decs: t.Expression[] = [];
for (let i = 0; i < decsCount; i++) {
if (version === "2023-03" && hasOneThis) {
if (version === "2023-05" && hasOneThis) {
decs.push(
decoratorsThis[i] || t.unaryExpression("void", t.numericLiteral(0)),
);
Expand All @@ -380,7 +380,7 @@ function generateDecorationExprs(

let flag = el.kind;
if (el.isStatic) {
flag += version === "2023-03" ? STATIC : STATIC_OLD_VERSION;
flag += version === "2023-05" ? STATIC : STATIC_OLD_VERSION;
}
if (hasThis) flag += DECORATORS_HAVE_THIS;

Expand Down Expand Up @@ -589,7 +589,7 @@ function transformClass(
const decoratorsThis = new Map<t.Decorator, t.Expression>();
const maybeExtractDecorator = (decorator: t.Decorator) => {
const { expression } = decorator;
if (version === "2023-03" && t.isMemberExpression(expression)) {
if (version === "2023-05" && t.isMemberExpression(expression)) {
let object;
if (
t.isSuper(expression.object) ||
Expand Down Expand Up @@ -1132,7 +1132,7 @@ function createLocalsAssignment(
);
} else {
// TODO(Babel 8): Only keep the if branch
if (version === "2023-03") {
if (version === "2023-05") {
if (maybePrivateBranName || classDecorationsFlag.value !== 0) {
args.push(classDecorationsFlag);
}
Expand All @@ -1143,7 +1143,7 @@ function createLocalsAssignment(
` as t.ArrowFunctionExpression,
);
}
rhs = t.callExpression(state.addHelper("applyDecs2303"), args);
rhs = t.callExpression(state.addHelper("applyDecs2305"), args);
} else if (version === "2023-01") {
if (maybePrivateBranName) {
args.push(
Expand Down Expand Up @@ -1180,9 +1180,9 @@ function createLocalsAssignment(
export default function (
{ assertVersion, assumption }: PluginAPI,
{ loose }: Options,
version: "2023-03" | "2023-01" | "2022-03" | "2021-12",
version: "2023-05" | "2023-01" | "2022-03" | "2021-12",
): PluginObject {
if (version === "2023-03" || version === "2023-01") {
if (version === "2023-05" || version === "2023-01") {
assertVersion("^7.21.0");
} else if (version === "2021-12") {
assertVersion("^7.16.0");
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,6 +1,6 @@
{
"plugins": [
["proposal-decorators", { "version": "2023-03" }],
["proposal-decorators", { "version": "2023-05" }],
"proposal-class-properties",
"proposal-private-methods",
"proposal-class-static-block"
Expand Down
Expand Up @@ -36,4 +36,4 @@ function _set_b2(v) {
function _get_b2() {
return _get_b(this);
}
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initProto] = babelHelpers.applyDecs2303(Foo, [[dec, 1, "a", o => babelHelpers.classPrivateFieldGet(o, _A), (o, v) => babelHelpers.classPrivateFieldSet(o, _A, v)], [dec, 1, "b", o => babelHelpers.classPrivateFieldGet(o, _B), (o, v) => babelHelpers.classPrivateFieldSet(o, _B, v)]], [], 0, _ => _a.has(babelHelpers.checkInRHS(_))).e;
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initProto] = babelHelpers.applyDecs2305(Foo, [[dec, 1, "a", o => babelHelpers.classPrivateFieldGet(o, _A), (o, v) => babelHelpers.classPrivateFieldSet(o, _A, v)], [dec, 1, "b", o => babelHelpers.classPrivateFieldGet(o, _B), (o, v) => babelHelpers.classPrivateFieldSet(o, _B, v)]], [], 0, _ => _a.has(babelHelpers.checkInRHS(_))).e;
Expand Up @@ -38,4 +38,4 @@ class Foo {
babelHelpers.classPrivateFieldSet(this, _C, v);
}
}
[_init_a, _init_b, _init_computedKey, _initProto] = babelHelpers.applyDecs2303(Foo, [[dec, 1, "a"], [dec, 1, "b"], [dec, 1, _computedKey]], []).e;
[_init_a, _init_b, _init_computedKey, _initProto] = babelHelpers.applyDecs2305(Foo, [[dec, 1, "a"], [dec, 1, "b"], [dec, 1, _computedKey]], []).e;
Expand Up @@ -27,7 +27,7 @@ function _get_b2() {
return _get_b(this);
}
(() => {
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic] = babelHelpers.applyDecs2303(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;
[_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);
})();
var _A = {
Expand Down
Expand Up @@ -22,7 +22,7 @@ class Foo {
}
}
(() => {
[_init_a, _init_b, _init_computedKey, _initStatic] = babelHelpers.applyDecs2303(Foo, [[dec, 9, "a"], [dec, 9, "b"], [dec, 9, _computedKey]], []).e;
[_init_a, _init_b, _init_computedKey, _initStatic] = babelHelpers.applyDecs2305(Foo, [[dec, 9, "a"], [dec, 9, "b"], [dec, 9, _computedKey]], []).e;
_initStatic(Foo);
})();
var _A = {
Expand Down
@@ -0,0 +1,3 @@
{
"plugins": [["proposal-decorators", { "version": "2023-05" }]]
}
Expand Up @@ -2,7 +2,7 @@ var _init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initProto;
const dec = () => {};
class Foo {
static {
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initProto] = babelHelpers.applyDecs2303(this, [[dec, 1, "a", o => o.#A, (o, v) => o.#A = v], [dec, 1, "b", o => o.#B, (o, v) => o.#B = v]], [], 0, _ => #a in _).e;
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initProto] = babelHelpers.applyDecs2305(this, [[dec, 1, "a", o => o.#A, (o, v) => o.#A = v], [dec, 1, "b", o => o.#B, (o, v) => o.#B = v]], [], 0, _ => #a in _).e;
}
#A = (_initProto(this), _init_a(this));
set #a(v) {
Expand Down
Expand Up @@ -3,7 +3,7 @@ const dec = () => {};
_computedKey = 'c';
class Foo {
static {
[_init_a, _init_b, _init_computedKey, _initProto] = babelHelpers.applyDecs2303(this, [[dec, 1, "a"], [dec, 1, "b"], [dec, 1, _computedKey]], []).e;
[_init_a, _init_b, _init_computedKey, _initProto] = babelHelpers.applyDecs2305(this, [[dec, 1, "a"], [dec, 1, "b"], [dec, 1, _computedKey]], []).e;
}
#A = (_initProto(this), _init_a(this));
get a() {
Expand Down
Expand Up @@ -2,7 +2,7 @@ var _init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic;
const dec = () => {};
class Foo {
static {
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic] = babelHelpers.applyDecs2303(this, [[dec, 9, "a", o => o.#A, (o, v) => o.#A = v], [dec, 9, "b", o => o.#B, (o, v) => o.#B = v]], []).e;
[_init_a, _get_a, _set_a, _init_b, _get_b, _set_b, _initStatic] = babelHelpers.applyDecs2305(this, [[dec, 9, "a", o => o.#A, (o, v) => o.#A = v], [dec, 9, "b", o => o.#B, (o, v) => o.#B = v]], []).e;
_initStatic(this);
}
static #A = _init_a(this);
Expand Down
Expand Up @@ -3,7 +3,7 @@ const dec = () => {};
_computedKey = 'c';
class Foo {
static {
[_init_a, _init_b, _init_computedKey, _initStatic] = babelHelpers.applyDecs2303(this, [[dec, 9, "a"], [dec, 9, "b"], [dec, 9, _computedKey]], []).e;
[_init_a, _init_b, _init_computedKey, _initStatic] = babelHelpers.applyDecs2305(this, [[dec, 9, "a"], [dec, 9, "b"], [dec, 9, _computedKey]], []).e;
_initStatic(this);
}
static #A = _init_a(this);
Expand Down
@@ -0,0 +1,6 @@
{
"plugins": [["proposal-decorators", { "version": "2023-05" }]],
"assumptions": {
"constantSuper": true
}
}
Expand Up @@ -3,7 +3,7 @@ const dec = () => {};
let _Foo;
class Foo extends Bar {
static {
[_Foo, _initClass] = babelHelpers.applyDecs2303(this, [], [dec]).c;
[_Foo, _initClass] = babelHelpers.applyDecs2305(this, [], [dec]).c;
}
constructor() {
let foo = super();
Expand Down
Expand Up @@ -2,7 +2,7 @@ var _call_x, _initProto;
const dec = () => {};
class Foo extends Bar {
static {
[_call_x, _initProto] = babelHelpers.applyDecs2303(this, [[dec, 3, "x", function () {
[_call_x, _initProto] = babelHelpers.applyDecs2305(this, [[dec, 3, "x", function () {
return Bar.prototype.foo.call(this);
}]], [], 0, _ => #x in _).e;
}
Expand Down
Expand Up @@ -2,7 +2,7 @@ var _call_x, _initProto;
const dec = () => {};
class Foo extends Bar {
static {
[_call_x, _initProto] = babelHelpers.applyDecs2303(this, [[dec, 2, "x", function () {
[_call_x, _initProto] = babelHelpers.applyDecs2305(this, [[dec, 2, "x", function () {
return Bar.prototype.foo.call(this);
}]], [], 0, _ => #x in _).e;
}
Expand Down
Expand Up @@ -14,5 +14,5 @@ class C {
({
e: [_init_m],
c: [_C, _initClass]
} = babelHelpers.applyDecs2303(C, [[memberDec, 0, "m"]], [classDec]));
} = babelHelpers.applyDecs2305(C, [[memberDec, 0, "m"]], [classDec]));
_initClass();
Expand Up @@ -15,5 +15,5 @@ class C {
({
e: [_initProto],
c: [_C, _initClass]
} = babelHelpers.applyDecs2303(C, [[memberDec, 2, "m"]], [classDec]));
} = babelHelpers.applyDecs2305(C, [[memberDec, 2, "m"]], [classDec]));
_initClass();

0 comments on commit 83ae4d2

Please sign in to comment.