From 335622f75db4c30159d33a62a205630da6c056ee Mon Sep 17 00:00:00 2001 From: Arthur Date: Mon, 10 Jan 2022 22:39:52 +0800 Subject: [PATCH] Delete useless check for variable redeclaration (#14129) --- packages/babel-traverse/src/scope/binding.ts | 2 +- packages/babel-traverse/src/scope/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/babel-traverse/src/scope/binding.ts b/packages/babel-traverse/src/scope/binding.ts index ea521ffac8..48f15692f8 100644 --- a/packages/babel-traverse/src/scope/binding.ts +++ b/packages/babel-traverse/src/scope/binding.ts @@ -2,7 +2,7 @@ import type NodePath from "../path"; import type * as t from "@babel/types"; import type Scope from "./index"; -type BindingKind = +export type BindingKind = | "var" /* var declarator */ | "let" /* let declarator, class declaration id, catch clause parameters */ | "const" /* const declarator */ diff --git a/packages/babel-traverse/src/scope/index.ts b/packages/babel-traverse/src/scope/index.ts index 71e43ebb00..068b67b5b2 100644 --- a/packages/babel-traverse/src/scope/index.ts +++ b/packages/babel-traverse/src/scope/index.ts @@ -3,6 +3,7 @@ import type NodePath from "../path"; import traverse from "../index"; import type { TraverseOptions } from "../index"; import Binding from "./binding"; +import type { BindingKind } from "./binding"; import globals from "globals"; import { NOT_LOCAL_BINDING, @@ -569,7 +570,7 @@ export default class Scope { checkBlockScopedCollisions( local: Binding, - kind: string, + kind: BindingKind, name: string, id: any, ) { @@ -587,7 +588,7 @@ export default class Scope { local.kind === "const" || local.kind === "module" || // don't allow a local of param with a kind of let - (local.kind === "param" && (kind === "let" || kind === "const")); + (local.kind === "param" && kind === "const"); if (duplicate) { throw this.hub.buildError(