babel__traverse: allow undefined scope for both traverse functions (#35840)

This commit is contained in:
Jake Runzer 2019-06-11 02:30:45 +01:00 committed by Andrew Casey
parent 50578128bb
commit d689e2b616
2 changed files with 16 additions and 2 deletions

View File

@ -149,6 +149,8 @@ const VisitorStateTest: Visitor<SomeVisitorState> = {
}
};
traverse(ast, VisitorStateTest, undefined, { someState: "test" });
const VisitorAliasTest: Visitor = {
Function() {},
Expression() {},

View File

@ -11,8 +11,20 @@ import * as t from "@babel/types";
export type Node = t.Node;
export default function traverse<S>(parent: Node | Node[], opts: TraverseOptions<S>, scope: Scope, state: S, parentPath?: NodePath): void;
export default function traverse(parent: Node | Node[], opts: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void;
export default function traverse<S>(
parent: Node | Node[],
opts: TraverseOptions<S>,
scope: Scope | undefined,
state: S,
parentPath?: NodePath,
): void;
export default function traverse(
parent: Node | Node[],
opts: TraverseOptions,
scope?: Scope,
state?: any,
parentPath?: NodePath,
): void;
export interface TraverseOptions<S = Node> extends Visitor<S> {
scope?: Scope;