• Type Parameters

    • S

    Parameters

    • parent: Node
    • opts: TraverseOptions<S>
    • scope: Scope
    • state: S
    • OptionalparentPath: NodePath<Node>

    Returns void

  • Parameters

    • parent: Node
    • Optionalopts: TraverseOptions<Node>
    • Optionalscope: Scope
    • Optionalstate: any
    • OptionalparentPath: NodePath<Node>

    Returns void

Properties

cache: typeof cache
cheap: ((node: Node, enter: ((node: Node) => void)) => void)
clearNode: ((node: Node, opts?: Options) => void)
explode: (<S>(visitor: Visitor<S>) => {
    [Type in Exclude<Node, t.DeprecatedAliases>["type"]]?: VisitNodeObject<S, Extract<Node, {
        type: Type;
    }>>
})

Type declaration

    • <S>(visitor): {
          [Type in Exclude<Node, t.DeprecatedAliases>["type"]]?: VisitNodeObject<S, Extract<Node, {
              type: Type;
          }>>
      }
    • explode() will take a Visitor object with all of the various shorthands that we support, and validates & normalizes it into a common format, ready to be used in traversal.

      The various shorthands are:

      • Identifier() { ... } -> Identifier: { enter() { ... } }
      • "Identifier|NumericLiteral": { ... } -> Identifier: { ... }, NumericLiteral: { ... }
      • Aliases in @babel/types: e.g. Property: { ... } -> ObjectProperty: { ... }, ClassProperty: { ... }

      Other normalizations are:

      • Visitors of virtual types are wrapped, so that they are only visited when their dynamic check passes
      • enter and exit functions are wrapped in arrays, to ease merging of visitors

      Type Parameters

      • S = unknown

      Parameters

      • visitor: Visitor<S>

      Returns {
          [Type in Exclude<Node, t.DeprecatedAliases>["type"]]?: VisitNodeObject<S, Extract<Node, {
              type: Type;
          }>>
      }

hasType: ((tree: Node, type:
    | "ImportDefaultSpecifier"
    | "ImportSpecifier"
    | "ImportNamespaceSpecifier"
    | "JSXElement"
    | "ArrayExpression"
    | "ArrowFunctionExpression"
    | "AssignmentExpression"
    | "AwaitExpression"
    | "BigIntLiteral"
    | "BinaryExpression"
    | "BindExpression"
    | "BooleanLiteral"
    | "CallExpression"
    | "ClassExpression"
    | "ConditionalExpression"
    | "DecimalLiteral"
    | "DoExpression"
    | "FunctionExpression"
    | "Identifier"
    | "Import"
    | "ImportExpression"
    | "JSXFragment"
    | "LogicalExpression"
    | "MemberExpression"
    | "MetaProperty"
    | "ModuleExpression"
    | "NewExpression"
    | "NullLiteral"
    | "NumericLiteral"
    | "ObjectExpression"
    | "OptionalCallExpression"
    | "OptionalMemberExpression"
    | "ParenthesizedExpression"
    | "PipelineBareFunction"
    | "PipelinePrimaryTopicReference"
    | "PipelineTopicExpression"
    | "RecordExpression"
    | "RegExpLiteral"
    | "SequenceExpression"
    | "StringLiteral"
    | "Super"
    | "TSAsExpression"
    | "TSInstantiationExpression"
    | "TSNonNullExpression"
    | "TSSatisfiesExpression"
    | "TSTypeAssertion"
    | "TaggedTemplateExpression"
    | "TemplateLiteral"
    | "ThisExpression"
    | "TopicReference"
    | "TupleExpression"
    | "TypeCastExpression"
    | "UnaryExpression"
    | "UpdateExpression"
    | "YieldExpression"
    | "JSXIdentifier"
    | "JSXMemberExpression"
    | "PrivateName"
    | "AnyTypeAnnotation"
    | "ArgumentPlaceholder"
    | "ArrayPattern"
    | "ArrayTypeAnnotation"
    | "AssignmentPattern"
    | "BlockStatement"
    | "BooleanLiteralTypeAnnotation"
    | "BooleanTypeAnnotation"
    | "BreakStatement"
    | "CatchClause"
    | "ClassAccessorProperty"
    | "ClassBody"
    | "ClassDeclaration"
    | "ClassImplements"
    | "ClassMethod"
    | "ClassPrivateMethod"
    | "ClassPrivateProperty"
    | "ClassProperty"
    | "ContinueStatement"
    | "DebuggerStatement"
    | "DeclareClass"
    | "DeclareExportAllDeclaration"
    | "DeclareExportDeclaration"
    | "DeclareFunction"
    | "DeclareInterface"
    | "DeclareModule"
    | "DeclareModuleExports"
    | "DeclareOpaqueType"
    | "DeclareTypeAlias"
    | "DeclareVariable"
    | "DeclaredPredicate"
    | "Decorator"
    | "Directive"
    | "DirectiveLiteral"
    | "DoWhileStatement"
    | "EmptyStatement"
    | "EmptyTypeAnnotation"
    | "EnumBooleanBody"
    | "EnumBooleanMember"
    | "EnumDeclaration"
    | "EnumDefaultedMember"
    | "EnumNumberBody"
    | "EnumNumberMember"
    | "EnumStringBody"
    | "EnumStringMember"
    | "EnumSymbolBody"
    | "ExistsTypeAnnotation"
    | "ExportAllDeclaration"
    | "ExportDefaultDeclaration"
    | "ExportDefaultSpecifier"
    | "ExportNamedDeclaration"
    | "ExportNamespaceSpecifier"
    | "ExportSpecifier"
    | "ExpressionStatement"
    | "File"
    | "ForInStatement"
    | "ForOfStatement"
    | "ForStatement"
    | "FunctionDeclaration"
    | "FunctionTypeAnnotation"
    | "FunctionTypeParam"
    | "GenericTypeAnnotation"
    | "IfStatement"
    | "ImportAttribute"
    | "ImportDeclaration"
    | "IndexedAccessType"
    | "InferredPredicate"
    | "InterfaceDeclaration"
    | "InterfaceExtends"
    | "InterfaceTypeAnnotation"
    | "InterpreterDirective"
    | "IntersectionTypeAnnotation"
    | "JSXAttribute"
    | "JSXClosingElement"
    | "JSXClosingFragment"
    | "JSXEmptyExpression"
    | "JSXExpressionContainer"
    | "JSXNamespacedName"
    | "JSXOpeningElement"
    | "JSXOpeningFragment"
    | "JSXSpreadAttribute"
    | "JSXSpreadChild"
    | "JSXText"
    | "LabeledStatement"
    | "MixedTypeAnnotation"
    | "Noop"
    | "NullLiteralTypeAnnotation"
    | "NullableTypeAnnotation"
    | "NumberLiteral"
    | "NumberLiteralTypeAnnotation"
    | "NumberTypeAnnotation"
    | "ObjectMethod"
    | "ObjectPattern"
    | "ObjectProperty"
    | "ObjectTypeAnnotation"
    | "ObjectTypeCallProperty"
    | "ObjectTypeIndexer"
    | "ObjectTypeInternalSlot"
    | "ObjectTypeProperty"
    | "ObjectTypeSpreadProperty"
    | "OpaqueType"
    | "OptionalIndexedAccessType"
    | "Placeholder"
    | "Program"
    | "QualifiedTypeIdentifier"
    | "RegexLiteral"
    | "RestElement"
    | "RestProperty"
    | "ReturnStatement"
    | "SpreadElement"
    | "SpreadProperty"
    | "StaticBlock"
    | "StringLiteralTypeAnnotation"
    | "StringTypeAnnotation"
    | "SwitchCase"
    | "SwitchStatement"
    | "SymbolTypeAnnotation"
    | "TSAnyKeyword"
    | "TSArrayType"
    | "TSBigIntKeyword"
    | "TSBooleanKeyword"
    | "TSCallSignatureDeclaration"
    | "TSConditionalType"
    | "TSConstructSignatureDeclaration"
    | "TSConstructorType"
    | "TSDeclareFunction"
    | "TSDeclareMethod"
    | "TSEnumDeclaration"
    | "TSEnumMember"
    | "TSExportAssignment"
    | "TSExpressionWithTypeArguments"
    | "TSExternalModuleReference"
    | "TSFunctionType"
    | "TSImportEqualsDeclaration"
    | "TSImportType"
    | "TSIndexSignature"
    | "TSIndexedAccessType"
    | "TSInferType"
    | "TSInterfaceBody"
    | "TSInterfaceDeclaration"
    | "TSIntersectionType"
    | "TSIntrinsicKeyword"
    | "TSLiteralType"
    | "TSMappedType"
    | "TSMethodSignature"
    | "TSModuleBlock"
    | "TSModuleDeclaration"
    | "TSNamedTupleMember"
    | "TSNamespaceExportDeclaration"
    | "TSNeverKeyword"
    | "TSNullKeyword"
    | "TSNumberKeyword"
    | "TSObjectKeyword"
    | "TSOptionalType"
    | "TSParameterProperty"
    | "TSParenthesizedType"
    | "TSPropertySignature"
    | "TSQualifiedName"
    | "TSRestType"
    | "TSStringKeyword"
    | "TSSymbolKeyword"
    | "TSThisType"
    | "TSTupleType"
    | "TSTypeAliasDeclaration"
    | "TSTypeAnnotation"
    | "TSTypeLiteral"
    | "TSTypeOperator"
    | "TSTypeParameter"
    | "TSTypeParameterDeclaration"
    | "TSTypeParameterInstantiation"
    | "TSTypePredicate"
    | "TSTypeQuery"
    | "TSTypeReference"
    | "TSUndefinedKeyword"
    | "TSUnionType"
    | "TSUnknownKeyword"
    | "TSVoidKeyword"
    | "TemplateElement"
    | "ThisTypeAnnotation"
    | "ThrowStatement"
    | "TryStatement"
    | "TupleTypeAnnotation"
    | "TypeAlias"
    | "TypeAnnotation"
    | "TypeParameter"
    | "TypeParameterDeclaration"
    | "TypeParameterInstantiation"
    | "TypeofTypeAnnotation"
    | "UnionTypeAnnotation"
    | "V8IntrinsicIdentifier"
    | "VariableDeclaration"
    | "VariableDeclarator"
    | "Variance"
    | "VoidTypeAnnotation"
    | "WhileStatement"
    | "WithStatement", denylistTypes?: string[]) => boolean)
node: ((node: Node, opts: TraverseOptions<Node>, scope?: Scope, state?: any, path?: NodePath<Node>, skipKeys?: Record<string, boolean>) => void)
removeProperties: ((tree: Node, opts?: Options) => Node)
verify: ((visitor: Visitor<unknown>) => void)
visitors: typeof visitors