Merge pull request #18439 from marvinhagemeister/babel-plugin

Fix incorrect `this` binding in `babel-core` + `babel-traverse`
This commit is contained in:
Daniel Rosenwasser
2017-08-18 15:28:56 -07:00
committed by GitHub
3 changed files with 210 additions and 175 deletions

View File

@@ -27,3 +27,20 @@ babel.transformFile("filename.js", options, (err, result) => {
});
babel.transformFileSync("filename.js", options).code;
// Slightly modified example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-pre-and-post-in-plugins
export default function(): babel.PluginObj<{ cache: Map<string, number>}> {
return {
pre(state) {
this.cache = new Map();
},
visitor: {
StringLiteral(path) {
this.cache.set(path.node.value, 1);
}
},
post(state) {
return this.cache;
}
};
}

View File

@@ -6,13 +6,26 @@
// TypeScript Version: 2.3
import * as t from 'babel-types';
export {t as types};
export { t as types };
export type Node = t.Node;
export import template = require('babel-template');
export const version: string;
import traverse, { Visitor } from "babel-traverse";
export { traverse, Visitor };
// A babel plugin is a simple function which must return an object matching
// the following interface. Babel will throw if it finds unknown properties.
// The list of allowed plugin keys is here:
// https://github.com/babel/babel/blob/4e50b2d9d9c376cee7a2cbf56553fe5b982ea53c/packages/babel-core/src/config/option-manager.js#L71
export interface PluginObj<S = {}> {
name?: string;
manipulateOptions?(opts: any, parserOpts: any): void;
pre?(this: S, state: any): void;
visitor: Visitor<S>;
post?(this: S, state: any): void;
inherits?: any;
}
/** Transforms the passed in `code`. Returning an object with the generated code, source map, and AST. */
export function transform(code: string, opts?: TransformOptions): BabelFileResult;

View File

@@ -133,183 +133,188 @@ export class Binding {
constantViolations: NodePath[];
}
export interface Visitor extends VisitNodeObject<Node> {
ArrayExpression?: VisitNode<t.ArrayExpression>;
AssignmentExpression?: VisitNode<t.AssignmentExpression>;
LVal?: VisitNode<t.LVal>;
Expression?: VisitNode<t.Expression>;
BinaryExpression?: VisitNode<t.BinaryExpression>;
Directive?: VisitNode<t.Directive>;
DirectiveLiteral?: VisitNode<t.DirectiveLiteral>;
BlockStatement?: VisitNode<t.BlockStatement>;
BreakStatement?: VisitNode<t.BreakStatement>;
Identifier?: VisitNode<t.Identifier>;
CallExpression?: VisitNode<t.CallExpression>;
CatchClause?: VisitNode<t.CatchClause>;
ConditionalExpression?: VisitNode<t.ConditionalExpression>;
ContinueStatement?: VisitNode<t.ContinueStatement>;
DebuggerStatement?: VisitNode<t.DebuggerStatement>;
DoWhileStatement?: VisitNode<t.DoWhileStatement>;
Statement?: VisitNode<t.Statement>;
EmptyStatement?: VisitNode<t.EmptyStatement>;
ExpressionStatement?: VisitNode<t.ExpressionStatement>;
File?: VisitNode<t.File>;
Program?: VisitNode<t.Program>;
ForInStatement?: VisitNode<t.ForInStatement>;
VariableDeclaration?: VisitNode<t.VariableDeclaration>;
ForStatement?: VisitNode<t.ForStatement>;
FunctionDeclaration?: VisitNode<t.FunctionDeclaration>;
FunctionExpression?: VisitNode<t.FunctionExpression>;
IfStatement?: VisitNode<t.IfStatement>;
LabeledStatement?: VisitNode<t.LabeledStatement>;
StringLiteral?: VisitNode<t.StringLiteral>;
NumericLiteral?: VisitNode<t.NumericLiteral>;
NullLiteral?: VisitNode<t.NullLiteral>;
BooleanLiteral?: VisitNode<t.BooleanLiteral>;
RegExpLiteral?: VisitNode<t.RegExpLiteral>;
LogicalExpression?: VisitNode<t.LogicalExpression>;
MemberExpression?: VisitNode<t.MemberExpression>;
NewExpression?: VisitNode<t.NewExpression>;
ObjectExpression?: VisitNode<t.ObjectExpression>;
ObjectMethod?: VisitNode<t.ObjectMethod>;
ObjectProperty?: VisitNode<t.ObjectProperty>;
RestElement?: VisitNode<t.RestElement>;
ReturnStatement?: VisitNode<t.ReturnStatement>;
SequenceExpression?: VisitNode<t.SequenceExpression>;
SwitchCase?: VisitNode<t.SwitchCase>;
SwitchStatement?: VisitNode<t.SwitchStatement>;
ThisExpression?: VisitNode<t.ThisExpression>;
ThrowStatement?: VisitNode<t.ThrowStatement>;
TryStatement?: VisitNode<t.TryStatement>;
UnaryExpression?: VisitNode<t.UnaryExpression>;
UpdateExpression?: VisitNode<t.UpdateExpression>;
VariableDeclarator?: VisitNode<t.VariableDeclarator>;
WhileStatement?: VisitNode<t.WhileStatement>;
WithStatement?: VisitNode<t.WithStatement>;
AssignmentPattern?: VisitNode<t.AssignmentPattern>;
ArrayPattern?: VisitNode<t.ArrayPattern>;
ArrowFunctionExpression?: VisitNode<t.ArrowFunctionExpression>;
ClassBody?: VisitNode<t.ClassBody>;
ClassDeclaration?: VisitNode<t.ClassDeclaration>;
ClassExpression?: VisitNode<t.ClassExpression>;
ExportAllDeclaration?: VisitNode<t.ExportAllDeclaration>;
ExportDefaultDeclaration?: VisitNode<t.ExportDefaultDeclaration>;
ExportNamedDeclaration?: VisitNode<t.ExportNamedDeclaration>;
Declaration?: VisitNode<t.Declaration>;
ExportSpecifier?: VisitNode<t.ExportSpecifier>;
ForOfStatement?: VisitNode<t.ForOfStatement>;
ImportDeclaration?: VisitNode<t.ImportDeclaration>;
ImportDefaultSpecifier?: VisitNode<t.ImportDefaultSpecifier>;
ImportNamespaceSpecifier?: VisitNode<t.ImportNamespaceSpecifier>;
ImportSpecifier?: VisitNode<t.ImportSpecifier>;
MetaProperty?: VisitNode<t.MetaProperty>;
ClassMethod?: VisitNode<t.ClassMethod>;
ObjectPattern?: VisitNode<t.ObjectPattern>;
SpreadElement?: VisitNode<t.SpreadElement>;
Super?: VisitNode<t.Super>;
TaggedTemplateExpression?: VisitNode<t.TaggedTemplateExpression>;
TemplateLiteral?: VisitNode<t.TemplateLiteral>;
TemplateElement?: VisitNode<t.TemplateElement>;
YieldExpression?: VisitNode<t.YieldExpression>;
AnyTypeAnnotation?: VisitNode<t.AnyTypeAnnotation>;
ArrayTypeAnnotation?: VisitNode<t.ArrayTypeAnnotation>;
BooleanTypeAnnotation?: VisitNode<t.BooleanTypeAnnotation>;
BooleanLiteralTypeAnnotation?: VisitNode<t.BooleanLiteralTypeAnnotation>;
NullLiteralTypeAnnotation?: VisitNode<t.NullLiteralTypeAnnotation>;
ClassImplements?: VisitNode<t.ClassImplements>;
ClassProperty?: VisitNode<t.ClassProperty>;
DeclareClass?: VisitNode<t.DeclareClass>;
DeclareFunction?: VisitNode<t.DeclareFunction>;
DeclareInterface?: VisitNode<t.DeclareInterface>;
DeclareModule?: VisitNode<t.DeclareModule>;
DeclareTypeAlias?: VisitNode<t.DeclareTypeAlias>;
DeclareVariable?: VisitNode<t.DeclareVariable>;
ExistentialTypeParam?: VisitNode<t.ExistentialTypeParam>;
FunctionTypeAnnotation?: VisitNode<t.FunctionTypeAnnotation>;
FunctionTypeParam?: VisitNode<t.FunctionTypeParam>;
GenericTypeAnnotation?: VisitNode<t.GenericTypeAnnotation>;
InterfaceExtends?: VisitNode<t.InterfaceExtends>;
InterfaceDeclaration?: VisitNode<t.InterfaceDeclaration>;
IntersectionTypeAnnotation?: VisitNode<t.IntersectionTypeAnnotation>;
MixedTypeAnnotation?: VisitNode<t.MixedTypeAnnotation>;
NullableTypeAnnotation?: VisitNode<t.NullableTypeAnnotation>;
NumericLiteralTypeAnnotation?: VisitNode<t.NumericLiteralTypeAnnotation>;
NumberTypeAnnotation?: VisitNode<t.NumberTypeAnnotation>;
StringLiteralTypeAnnotation?: VisitNode<t.StringLiteralTypeAnnotation>;
StringTypeAnnotation?: VisitNode<t.StringTypeAnnotation>;
ThisTypeAnnotation?: VisitNode<t.ThisTypeAnnotation>;
TupleTypeAnnotation?: VisitNode<t.TupleTypeAnnotation>;
TypeofTypeAnnotation?: VisitNode<t.TypeofTypeAnnotation>;
TypeAlias?: VisitNode<t.TypeAlias>;
TypeAnnotation?: VisitNode<t.TypeAnnotation>;
TypeCastExpression?: VisitNode<t.TypeCastExpression>;
TypeParameterDeclaration?: VisitNode<t.TypeParameterDeclaration>;
TypeParameterInstantiation?: VisitNode<t.TypeParameterInstantiation>;
ObjectTypeAnnotation?: VisitNode<t.ObjectTypeAnnotation>;
ObjectTypeCallProperty?: VisitNode<t.ObjectTypeCallProperty>;
ObjectTypeIndexer?: VisitNode<t.ObjectTypeIndexer>;
ObjectTypeProperty?: VisitNode<t.ObjectTypeProperty>;
QualifiedTypeIdentifier?: VisitNode<t.QualifiedTypeIdentifier>;
UnionTypeAnnotation?: VisitNode<t.UnionTypeAnnotation>;
VoidTypeAnnotation?: VisitNode<t.VoidTypeAnnotation>;
JSXAttribute?: VisitNode<t.JSXAttribute>;
JSXIdentifier?: VisitNode<t.JSXIdentifier>;
JSXNamespacedName?: VisitNode<t.JSXNamespacedName>;
JSXElement?: VisitNode<t.JSXElement>;
JSXExpressionContainer?: VisitNode<t.JSXExpressionContainer>;
JSXClosingElement?: VisitNode<t.JSXClosingElement>;
JSXMemberExpression?: VisitNode<t.JSXMemberExpression>;
JSXOpeningElement?: VisitNode<t.JSXOpeningElement>;
JSXEmptyExpression?: VisitNode<t.JSXEmptyExpression>;
JSXSpreadAttribute?: VisitNode<t.JSXSpreadAttribute>;
JSXText?: VisitNode<t.JSXText>;
Noop?: VisitNode<t.Noop>;
ParenthesizedExpression?: VisitNode<t.ParenthesizedExpression>;
AwaitExpression?: VisitNode<t.AwaitExpression>;
BindExpression?: VisitNode<t.BindExpression>;
Decorator?: VisitNode<t.Decorator>;
DoExpression?: VisitNode<t.DoExpression>;
ExportDefaultSpecifier?: VisitNode<t.ExportDefaultSpecifier>;
ExportNamespaceSpecifier?: VisitNode<t.ExportNamespaceSpecifier>;
RestProperty?: VisitNode<t.RestProperty>;
SpreadProperty?: VisitNode<t.SpreadProperty>;
Binary?: VisitNode<t.Binary>;
Scopable?: VisitNode<t.Scopable>;
BlockParent?: VisitNode<t.BlockParent>;
Block?: VisitNode<t.Block>;
Terminatorless?: VisitNode<t.Terminatorless>;
CompletionStatement?: VisitNode<t.CompletionStatement>;
Conditional?: VisitNode<t.Conditional>;
Loop?: VisitNode<t.Loop>;
While?: VisitNode<t.While>;
ExpressionWrapper?: VisitNode<t.ExpressionWrapper>;
For?: VisitNode<t.For>;
ForXStatement?: VisitNode<t.ForXStatement>;
Function?: VisitNode<t.Function>;
FunctionParent?: VisitNode<t.FunctionParent>;
Pureish?: VisitNode<t.Pureish>;
Literal?: VisitNode<t.Literal>;
Immutable?: VisitNode<t.Immutable>;
UserWhitespacable?: VisitNode<t.UserWhitespacable>;
Method?: VisitNode<t.Method>;
ObjectMember?: VisitNode<t.ObjectMember>;
Property?: VisitNode<t.Property>;
UnaryLike?: VisitNode<t.UnaryLike>;
Pattern?: VisitNode<t.Pattern>;
Class?: VisitNode<t.Class>;
ModuleDeclaration?: VisitNode<t.ModuleDeclaration>;
ExportDeclaration?: VisitNode<t.ExportDeclaration>;
ModuleSpecifier?: VisitNode<t.ModuleSpecifier>;
Flow?: VisitNode<t.Flow>;
FlowBaseAnnotation?: VisitNode<t.FlowBaseAnnotation>;
FlowDeclaration?: VisitNode<t.FlowDeclaration>;
JSX?: VisitNode<t.JSX>;
Scope?: VisitNode<t.Scopable>;
// The Visitor has to be generic because babel binds `this` for each property.
// `this` is usually used in babel plugins to pass plugin state from
// `pre` -> `visitor` -> `post`. An example of this can be seen in the official
// babel handbook:
// https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#-pre-and-post-in-plugins
export interface Visitor<S = Node> extends VisitNodeObject<Node> {
ArrayExpression?: VisitNode<S, t.ArrayExpression>;
AssignmentExpression?: VisitNode<S, t.AssignmentExpression>;
LVal?: VisitNode<S, t.LVal>;
Expression?: VisitNode<S, t.Expression>;
BinaryExpression?: VisitNode<S, t.BinaryExpression>;
Directive?: VisitNode<S, t.Directive>;
DirectiveLiteral?: VisitNode<S, t.DirectiveLiteral>;
BlockStatement?: VisitNode<S, t.BlockStatement>;
BreakStatement?: VisitNode<S, t.BreakStatement>;
Identifier?: VisitNode<S, t.Identifier>;
CallExpression?: VisitNode<S, t.CallExpression>;
CatchClause?: VisitNode<S, t.CatchClause>;
ConditionalExpression?: VisitNode<S, t.ConditionalExpression>;
ContinueStatement?: VisitNode<S, t.ContinueStatement>;
DebuggerStatement?: VisitNode<S, t.DebuggerStatement>;
DoWhileStatement?: VisitNode<S, t.DoWhileStatement>;
Statement?: VisitNode<S, t.Statement>;
EmptyStatement?: VisitNode<S, t.EmptyStatement>;
ExpressionStatement?: VisitNode<S, t.ExpressionStatement>;
File?: VisitNode<S, t.File>;
Program?: VisitNode<S, t.Program>;
ForInStatement?: VisitNode<S, t.ForInStatement>;
VariableDeclaration?: VisitNode<S, t.VariableDeclaration>;
ForStatement?: VisitNode<S, t.ForStatement>;
FunctionDeclaration?: VisitNode<S, t.FunctionDeclaration>;
FunctionExpression?: VisitNode<S, t.FunctionExpression>;
IfStatement?: VisitNode<S, t.IfStatement>;
LabeledStatement?: VisitNode<S, t.LabeledStatement>;
StringLiteral?: VisitNode<S, t.StringLiteral>;
NumericLiteral?: VisitNode<S, t.NumericLiteral>;
NullLiteral?: VisitNode<S, t.NullLiteral>;
BooleanLiteral?: VisitNode<S, t.BooleanLiteral>;
RegExpLiteral?: VisitNode<S, t.RegExpLiteral>;
LogicalExpression?: VisitNode<S, t.LogicalExpression>;
MemberExpression?: VisitNode<S, t.MemberExpression>;
NewExpression?: VisitNode<S, t.NewExpression>;
ObjectExpression?: VisitNode<S, t.ObjectExpression>;
ObjectMethod?: VisitNode<S, t.ObjectMethod>;
ObjectProperty?: VisitNode<S, t.ObjectProperty>;
RestElement?: VisitNode<S, t.RestElement>;
ReturnStatement?: VisitNode<S, t.ReturnStatement>;
SequenceExpression?: VisitNode<S, t.SequenceExpression>;
SwitchCase?: VisitNode<S, t.SwitchCase>;
SwitchStatement?: VisitNode<S, t.SwitchStatement>;
ThisExpression?: VisitNode<S, t.ThisExpression>;
ThrowStatement?: VisitNode<S, t.ThrowStatement>;
TryStatement?: VisitNode<S, t.TryStatement>;
UnaryExpression?: VisitNode<S, t.UnaryExpression>;
UpdateExpression?: VisitNode<S, t.UpdateExpression>;
VariableDeclarator?: VisitNode<S, t.VariableDeclarator>;
WhileStatement?: VisitNode<S, t.WhileStatement>;
WithStatement?: VisitNode<S, t.WithStatement>;
AssignmentPattern?: VisitNode<S, t.AssignmentPattern>;
ArrayPattern?: VisitNode<S, t.ArrayPattern>;
ArrowFunctionExpression?: VisitNode<S, t.ArrowFunctionExpression>;
ClassBody?: VisitNode<S, t.ClassBody>;
ClassDeclaration?: VisitNode<S, t.ClassDeclaration>;
ClassExpression?: VisitNode<S, t.ClassExpression>;
ExportAllDeclaration?: VisitNode<S, t.ExportAllDeclaration>;
ExportDefaultDeclaration?: VisitNode<S, t.ExportDefaultDeclaration>;
ExportNamedDeclaration?: VisitNode<S, t.ExportNamedDeclaration>;
Declaration?: VisitNode<S, t.Declaration>;
ExportSpecifier?: VisitNode<S, t.ExportSpecifier>;
ForOfStatement?: VisitNode<S, t.ForOfStatement>;
ImportDeclaration?: VisitNode<S, t.ImportDeclaration>;
ImportDefaultSpecifier?: VisitNode<S, t.ImportDefaultSpecifier>;
ImportNamespaceSpecifier?: VisitNode<S, t.ImportNamespaceSpecifier>;
ImportSpecifier?: VisitNode<S, t.ImportSpecifier>;
MetaProperty?: VisitNode<S, t.MetaProperty>;
ClassMethod?: VisitNode<S, t.ClassMethod>;
ObjectPattern?: VisitNode<S, t.ObjectPattern>;
SpreadElement?: VisitNode<S, t.SpreadElement>;
Super?: VisitNode<S, t.Super>;
TaggedTemplateExpression?: VisitNode<S, t.TaggedTemplateExpression>;
TemplateLiteral?: VisitNode<S, t.TemplateLiteral>;
TemplateElement?: VisitNode<S, t.TemplateElement>;
YieldExpression?: VisitNode<S, t.YieldExpression>;
AnyTypeAnnotation?: VisitNode<S, t.AnyTypeAnnotation>;
ArrayTypeAnnotation?: VisitNode<S, t.ArrayTypeAnnotation>;
BooleanTypeAnnotation?: VisitNode<S, t.BooleanTypeAnnotation>;
BooleanLiteralTypeAnnotation?: VisitNode<S, t.BooleanLiteralTypeAnnotation>;
NullLiteralTypeAnnotation?: VisitNode<S, t.NullLiteralTypeAnnotation>;
ClassImplements?: VisitNode<S, t.ClassImplements>;
ClassProperty?: VisitNode<S, t.ClassProperty>;
DeclareClass?: VisitNode<S, t.DeclareClass>;
DeclareFunction?: VisitNode<S, t.DeclareFunction>;
DeclareInterface?: VisitNode<S, t.DeclareInterface>;
DeclareModule?: VisitNode<S, t.DeclareModule>;
DeclareTypeAlias?: VisitNode<S, t.DeclareTypeAlias>;
DeclareVariable?: VisitNode<S, t.DeclareVariable>;
ExistentialTypeParam?: VisitNode<S, t.ExistentialTypeParam>;
FunctionTypeAnnotation?: VisitNode<S, t.FunctionTypeAnnotation>;
FunctionTypeParam?: VisitNode<S, t.FunctionTypeParam>;
GenericTypeAnnotation?: VisitNode<S, t.GenericTypeAnnotation>;
InterfaceExtends?: VisitNode<S, t.InterfaceExtends>;
InterfaceDeclaration?: VisitNode<S, t.InterfaceDeclaration>;
IntersectionTypeAnnotation?: VisitNode<S, t.IntersectionTypeAnnotation>;
MixedTypeAnnotation?: VisitNode<S, t.MixedTypeAnnotation>;
NullableTypeAnnotation?: VisitNode<S, t.NullableTypeAnnotation>;
NumericLiteralTypeAnnotation?: VisitNode<S, t.NumericLiteralTypeAnnotation>;
NumberTypeAnnotation?: VisitNode<S, t.NumberTypeAnnotation>;
StringLiteralTypeAnnotation?: VisitNode<S, t.StringLiteralTypeAnnotation>;
StringTypeAnnotation?: VisitNode<S, t.StringTypeAnnotation>;
ThisTypeAnnotation?: VisitNode<S, t.ThisTypeAnnotation>;
TupleTypeAnnotation?: VisitNode<S, t.TupleTypeAnnotation>;
TypeofTypeAnnotation?: VisitNode<S, t.TypeofTypeAnnotation>;
TypeAlias?: VisitNode<S, t.TypeAlias>;
TypeAnnotation?: VisitNode<S, t.TypeAnnotation>;
TypeCastExpression?: VisitNode<S, t.TypeCastExpression>;
TypeParameterDeclaration?: VisitNode<S, t.TypeParameterDeclaration>;
TypeParameterInstantiation?: VisitNode<S, t.TypeParameterInstantiation>;
ObjectTypeAnnotation?: VisitNode<S, t.ObjectTypeAnnotation>;
ObjectTypeCallProperty?: VisitNode<S, t.ObjectTypeCallProperty>;
ObjectTypeIndexer?: VisitNode<S, t.ObjectTypeIndexer>;
ObjectTypeProperty?: VisitNode<S, t.ObjectTypeProperty>;
QualifiedTypeIdentifier?: VisitNode<S, t.QualifiedTypeIdentifier>;
UnionTypeAnnotation?: VisitNode<S, t.UnionTypeAnnotation>;
VoidTypeAnnotation?: VisitNode<S, t.VoidTypeAnnotation>;
JSXAttribute?: VisitNode<S, t.JSXAttribute>;
JSXIdentifier?: VisitNode<S, t.JSXIdentifier>;
JSXNamespacedName?: VisitNode<S, t.JSXNamespacedName>;
JSXElement?: VisitNode<S, t.JSXElement>;
JSXExpressionContainer?: VisitNode<S, t.JSXExpressionContainer>;
JSXClosingElement?: VisitNode<S, t.JSXClosingElement>;
JSXMemberExpression?: VisitNode<S, t.JSXMemberExpression>;
JSXOpeningElement?: VisitNode<S, t.JSXOpeningElement>;
JSXEmptyExpression?: VisitNode<S, t.JSXEmptyExpression>;
JSXSpreadAttribute?: VisitNode<S, t.JSXSpreadAttribute>;
JSXText?: VisitNode<S, t.JSXText>;
Noop?: VisitNode<S, t.Noop>;
ParenthesizedExpression?: VisitNode<S, t.ParenthesizedExpression>;
AwaitExpression?: VisitNode<S, t.AwaitExpression>;
BindExpression?: VisitNode<S, t.BindExpression>;
Decorator?: VisitNode<S, t.Decorator>;
DoExpression?: VisitNode<S, t.DoExpression>;
ExportDefaultSpecifier?: VisitNode<S, t.ExportDefaultSpecifier>;
ExportNamespaceSpecifier?: VisitNode<S, t.ExportNamespaceSpecifier>;
RestProperty?: VisitNode<S, t.RestProperty>;
SpreadProperty?: VisitNode<S, t.SpreadProperty>;
Binary?: VisitNode<S, t.Binary>;
Scopable?: VisitNode<S, t.Scopable>;
BlockParent?: VisitNode<S, t.BlockParent>;
Block?: VisitNode<S, t.Block>;
Terminatorless?: VisitNode<S, t.Terminatorless>;
CompletionStatement?: VisitNode<S, t.CompletionStatement>;
Conditional?: VisitNode<S, t.Conditional>;
Loop?: VisitNode<S, t.Loop>;
While?: VisitNode<S, t.While>;
ExpressionWrapper?: VisitNode<S, t.ExpressionWrapper>;
For?: VisitNode<S, t.For>;
ForXStatement?: VisitNode<S, t.ForXStatement>;
Function?: VisitNode<S, t.Function>;
FunctionParent?: VisitNode<S, t.FunctionParent>;
Pureish?: VisitNode<S, t.Pureish>;
Literal?: VisitNode<S, t.Literal>;
Immutable?: VisitNode<S, t.Immutable>;
UserWhitespacable?: VisitNode<S, t.UserWhitespacable>;
Method?: VisitNode<S, t.Method>;
ObjectMember?: VisitNode<S, t.ObjectMember>;
Property?: VisitNode<S, t.Property>;
UnaryLike?: VisitNode<S, t.UnaryLike>;
Pattern?: VisitNode<S, t.Pattern>;
Class?: VisitNode<S, t.Class>;
ModuleDeclaration?: VisitNode<S, t.ModuleDeclaration>;
ExportDeclaration?: VisitNode<S, t.ExportDeclaration>;
ModuleSpecifier?: VisitNode<S, t.ModuleSpecifier>;
Flow?: VisitNode<S, t.Flow>;
FlowBaseAnnotation?: VisitNode<S, t.FlowBaseAnnotation>;
FlowDeclaration?: VisitNode<S, t.FlowDeclaration>;
JSX?: VisitNode<S, t.JSX>;
Scope?: VisitNode<S, t.Scopable>;
}
export type VisitNode<T> = VisitNodeFunction<T> | VisitNodeObject<T>;
export type VisitNode<T, P> = VisitNodeFunction<T, P> | VisitNodeObject<T>;
export type VisitNodeFunction<T> = (path: NodePath<T>, state: any) => void;
export type VisitNodeFunction<T, P> = (this: T, path: NodePath<P>, state: any) => void;
export interface VisitNodeObject<T> {
enter?(path: NodePath<T>, state: any): void;