Fix handling of this&co in computed keys in arrows transform (#14005)

This commit is contained in:
Nicolò Ribaudo
2021-11-30 22:54:17 +01:00
committed by GitHub
parent 893650130a
commit 36a5ac4145
20 changed files with 286 additions and 117 deletions

View File

@@ -1,9 +1,8 @@
import { template, traverse, types as t } from "@babel/core";
import type { File } from "@babel/core";
import type { NodePath, Visitor, Scope } from "@babel/traverse";
import ReplaceSupers, {
environmentVisitor,
} from "@babel/helper-replace-supers";
import ReplaceSupers from "@babel/helper-replace-supers";
import environmentVisitor from "@babel/helper-environment-visitor";
import memberExpressionToFunctions from "@babel/helper-member-expression-to-functions";
import type {
Handler,
@@ -851,7 +850,11 @@ function buildPrivateMethodDeclaration(
);
}
const thisContextVisitor = traverse.visitors.merge([
const thisContextVisitor = traverse.visitors.merge<{
classRef: t.Identifier;
needsClassRef: boolean;
innerBinding: t.Identifier;
}>([
{
ThisExpression(path, state) {
state.needsClassRef = true;

View File

@@ -1,9 +1,9 @@
import { template, traverse, types as t } from "@babel/core";
import type { File } from "@babel/core";
import type { NodePath, Scope, Visitor, Binding } from "@babel/traverse";
import { environmentVisitor } from "@babel/helper-replace-supers";
import environmentVisitor from "@babel/helper-environment-visitor";
const findBareSupers = traverse.visitors.merge([
const findBareSupers = traverse.visitors.merge<NodePath<t.CallExpression>[]>([
{
Super(path: NodePath<t.Super>) {
const { node, parentPath } = path;