// Type definitions for @babel/traverse 7.18 // Project: https://github.com/babel/babel/tree/main/packages/babel-traverse, https://babeljs.io // Definitions by: Troy Gerwien // Marvin Hagemeister // Ryan Petrich // Melvin Groenhoff // Dean L. // Ifiok Jr. // ExE Boss // Daniel Tschinder // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as t from '@babel/types'; export import Node = t.Node; declare const traverse: { ( parent: Node | Node[] | null | undefined, opts: TraverseOptions, scope: Scope | undefined, state: S, parentPath?: NodePath, ): void; ( parent: Node | Node[] | null | undefined, opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath, ): void; visitors: typeof visitors; verify: typeof visitors.verify; explode: typeof visitors.explode; }; export namespace visitors { /** * `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 */ function explode( visitor: Visitor, ): { [Type in Node['type']]?: VisitNodeObject>; }; function verify(visitor: Visitor): void; function merge(visitors: Array>, states?: S[]): Visitor; } export default traverse; export interface TraverseOptions extends Visitor { scope?: Scope | undefined; noScope?: boolean | undefined; } export type ArrayKeys = keyof { [P in keyof T as T[P] extends any[] ? P : never]: P }; export class Scope { constructor(path: NodePath, parentScope?: Scope); path: NodePath; block: Node; parentBlock: Node; parent: Scope; hub: HubInterface; bindings: { [name: string]: Binding }; /** Traverse node with current scope and path. */ traverse(node: Node | Node[], opts: TraverseOptions, state: S): void; traverse(node: Node | Node[], opts?: TraverseOptions, state?: any): void; /** Generate a unique identifier and add it to the current scope. */ generateDeclaredUidIdentifier(name?: string): t.Identifier; /** Generate a unique identifier. */ generateUidIdentifier(name?: string): t.Identifier; /** Generate a unique `_id1` binding. */ generateUid(name?: string): string; /** Generate a unique identifier based on a node. */ generateUidIdentifierBasedOnNode(parent: Node, defaultName?: string): t.Identifier; /** * Determine whether evaluating the specific input `node` is a consequenceless reference. ie. * evaluating it wont result in potentially arbitrary code from being ran. The following are * whitelisted and determined not to cause side effects: * * - `this` expressions * - `super` expressions * - Bound identifiers */ isStatic(node: Node): boolean; /** Possibly generate a memoised identifier if it is not static and has consequences. */ maybeGenerateMemoised(node: Node, dontPush?: boolean): t.Identifier; checkBlockScopedCollisions(local: Binding, kind: BindingKind, name: string, id: object): void; rename(oldName: string, newName?: string, block?: Node): void; dump(): void; toArray(node: Node, i?: number): Node; registerDeclaration(path: NodePath): void; buildUndefinedNode(): Node; registerConstantViolation(path: NodePath): void; registerBinding(kind: string, path: NodePath, bindingPath?: NodePath): void; addGlobal(node: Node): void; hasUid(name: string): boolean; hasGlobal(name: string): boolean; hasReference(name: string): boolean; isPure(node: Node, constantsOnly?: boolean): boolean; setData(key: string, val: any): any; getData(key: string): any; removeData(key: string): void; crawl(): void; push(opts: { id: t.LVal; init?: t.Expression | undefined; unique?: boolean | undefined; kind?: 'var' | 'let' | 'const' | undefined; }): void; getProgramParent(): Scope; getFunctionParent(): Scope | null; getBlockParent(): Scope; /** Walks the scope tree and gathers **all** bindings. */ getAllBindings(...kinds: string[]): object; bindingIdentifierEquals(name: string, node: Node): boolean; getBinding(name: string): Binding | undefined; getOwnBinding(name: string): Binding | undefined; getBindingIdentifier(name: string): t.Identifier; getOwnBindingIdentifier(name: string): t.Identifier; hasOwnBinding(name: string): boolean; hasBinding(name: string, noGlobals?: boolean): boolean; parentHasBinding(name: string, noGlobals?: boolean): boolean; /** Move a binding of `name` to another `scope`. */ moveBindingTo(name: string, scope: Scope): void; removeOwnBinding(name: string): void; removeBinding(name: string): void; } export type BindingKind = 'var' | 'let' | 'const' | 'module' | 'hoisted' | 'param' | 'local' | 'unknown'; export class Binding { constructor(opts: { identifier: t.Identifier; scope: Scope; path: NodePath; kind: BindingKind }); identifier: t.Identifier; scope: Scope; path: NodePath; kind: BindingKind; referenced: boolean; references: number; referencePaths: NodePath[]; constant: boolean; constantViolations: NodePath[]; hasDeoptedValue?: boolean; hasValue?: boolean; value?: any; deopValue(): void; setValue(value: any): void; clearValue(): void; reassign(path: NodePath): void; reference(path: NodePath): void; dereference(): void; } export type Visitor = VisitNodeObject & { [Type in Node['type']]?: VisitNode>; } & { [K in keyof t.Aliases]?: VisitNode; }; export type VisitNode = VisitNodeFunction | VisitNodeObject; export type VisitNodeFunction = (this: S, path: NodePath

, state: S) => void; type NodeType = Node['type'] | keyof t.Aliases; export interface VisitNodeObject { enter?: VisitNodeFunction | undefined; exit?: VisitNodeFunction | undefined; denylist?: NodeType[] | undefined; /** * @deprecated will be removed in Babel 8 */ blacklist?: NodeType[] | undefined; } export type NodePaths = T extends readonly Node[] ? { -readonly [K in keyof T]: NodePath> } : T extends Node ? [NodePath] : never; export class NodePath { constructor(hub: Hub, parent: Node); parent: Node; hub: Hub; contexts: TraversalContext[]; data: object; shouldSkip: boolean; shouldStop: boolean; removed: boolean; state: any; opts: object; skipKeys: object; parentPath: T extends t.Program ? null : NodePath; context: TraversalContext; container: object | object[]; listKey: string; inList: boolean; parentKey: string; key: string | number; node: T; scope: Scope; type: T extends null | undefined ? undefined : T extends Node ? T['type'] : string | undefined; typeAnnotation: object; getScope(scope: Scope): Scope; setData(key: string, val: any): any; getData(key: string, def?: any): any; hasNode(): this is NodePath>; buildCodeFrameError(msg: string, Error?: new (msg: string) => TError): TError; traverse(visitor: Visitor, state: T): void; traverse(visitor: Visitor): void; set(key: string, node: Node): void; getPathLocation(): string; // Example: https://github.com/babel/babel/blob/63204ae51e020d84a5b246312f5eeb4d981ab952/packages/babel-traverse/src/path/modification.js#L83 debug(buildMessage: () => string): void; static get(opts: { hub: HubInterface; parentPath: NodePath | null; parent: Node; container: C; listKey?: string | undefined; key: K; }): NodePath; //#region ------------------------- ancestry ------------------------- /** * Starting at the parent path of the current `NodePath` and going up the * tree, return the first `NodePath` that causes the provided `callback` * to return a truthy value, or `null` if the `callback` never returns a * truthy value. */ findParent(callback: (path: NodePath) => boolean): NodePath | null; /** * Starting at current `NodePath` and going up the tree, return the first * `NodePath` that causes the provided `callback` to return a truthy value, * or `null` if the `callback` never returns a truthy value. */ find(callback: (path: NodePath) => boolean): NodePath | null; /** Get the parent function of the current path. */ getFunctionParent(): NodePath | null; /** Walk up the tree until we hit a parent node path in a list. */ getStatementParent(): NodePath | null; /** * Get the deepest common ancestor and then from it, get the earliest relationship path * to that ancestor. * * Earliest is defined as being "before" all the other nodes in terms of list container * position and visiting key. */ getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath; /** Get the earliest path in the tree where the provided `paths` intersect. */ getDeepestCommonAncestorFrom( paths: NodePath[], filter?: (deepest: Node, i: number, ancestries: NodePath[]) => NodePath, ): NodePath; /** * Build an array of node paths containing the entire ancestry of the current node path. * * NOTE: The current node path is included in this. */ getAncestry(): [this, ...NodePath[]]; /** * A helper to find if `this` path is an ancestor of `maybeDescendant` */ isAncestor(maybeDescendant: NodePath): boolean; /** * A helper to find if `this` path is a descendant of `maybeAncestor` */ isDescendant(maybeAncestor: NodePath): boolean; inType(...candidateTypes: string[]): boolean; //#endregion //#region ------------------------- inference ------------------------- /** Infer the type of the current `NodePath`. */ getTypeAnnotation(): t.FlowType; isBaseType(baseName: string, soft?: boolean): boolean; couldBeBaseType(name: string): boolean; baseTypeStrictlyMatches(right: NodePath): boolean; isGenericType(genericName: string): boolean; //#endregion //#region ------------------------- replacement ------------------------- /** * Replace a node with an array of multiple. This method performs the following steps: * * - Inherit the comments of first provided node with that of the current node. * - Insert the provided nodes after the current node. * - Remove the current node. */ replaceWithMultiple(nodes: Nodes): NodePaths; /** * Parse a string as an expression and replace the current node with the result. * * NOTE: This is typically not a good idea to use. Building source strings when * transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's * easier to use, your transforms will be extremely brittle. */ replaceWithSourceString(replacement: any): [NodePath]; /** Replace the current node with another. */ replaceWith(replacement: T | NodePath): [NodePath]; /** * This method takes an array of statements nodes and then explodes it * into expressions. This method retains completion records which is * extremely important to retain original semantics. */ replaceExpressionWithStatements(nodes: Nodes): NodePaths; replaceInline(nodes: Nodes): NodePaths; //#endregion //#region ------------------------- evaluation ------------------------- /** * Walk the input `node` and statically evaluate if it's truthy. * * Returning `true` when we're sure that the expression will evaluate to a * truthy value, `false` if we're sure that it will evaluate to a falsy * value and `undefined` if we aren't sure. Because of this please do not * rely on coercion when using this method and check with === if it's false. */ evaluateTruthy(): boolean; /** * Walk the input `node` and statically evaluate it. * * Returns an object in the form `{ confident, value }`. `confident` indicates * whether or not we had to drop out of evaluating the expression because of * hitting an unknown node that we couldn't confidently find the value of. * * Example: * * t.evaluate(parse("5 + 5")) // { confident: true, value: 10 } * t.evaluate(parse("!true")) // { confident: true, value: false } * t.evaluate(parse("foo + foo")) // { confident: false, value: undefined } */ evaluate(): { confident: boolean; value: any }; //#endregion //#region ------------------------- introspection ------------------------- /** * Match the current node if it matches the provided `pattern`. * * For example, given the match `React.createClass` it would match the * parsed nodes of `React.createClass` and `React["createClass"]`. */ matchesPattern(pattern: string, allowPartial?: boolean): boolean; /** * Check whether we have the input `key`. If the `key` references an array then we check * if the array has any items, otherwise we just check if it's falsy. */ has(key: string): boolean; isStatic(): boolean; /** Alias of `has`. */ is(key: string): boolean; /** Opposite of `has`. */ isnt(key: string): boolean; /** Check whether the path node `key` strict equals `value`. */ equals(key: string, value: any): boolean; /** * Check the type against our stored internal type of the node. This is handy when a node has * been removed yet we still internally know the type and need it to calculate node replacement. */ isNodeType(type: string): boolean; /** * This checks whether or not we're in one of the following positions: * * for (KEY in right); * for (KEY;;); * * This is because these spots allow VariableDeclarations AND normal expressions so we need * to tell the path replacement that it's ok to replace this with an expression. */ canHaveVariableDeclarationOrExpression(): boolean; /** * This checks whether we are swapping an arrow function's body between an * expression and a block statement (or vice versa). * * This is because arrow functions may implicitly return an expression, which * is the same as containing a block statement. */ canSwapBetweenExpressionAndStatement(replacement: Node): boolean; /** Check whether the current path references a completion record */ isCompletionRecord(allowInsideFunction?: boolean): boolean; /** * Check whether or not the current `key` allows either a single statement or block statement * so we can explode it if necessary. */ isStatementOrBlock(): boolean; /** Check if the currently assigned path references the `importName` of `moduleSource`. */ referencesImport(moduleSource: string, importName: string): boolean; /** Get the source code associated with this node. */ getSource(): string; /** Check if the current path will maybe execute before another path */ willIMaybeExecuteBefore(path: NodePath): boolean; //#endregion //#region ------------------------- context ------------------------- call(key: string): boolean; isBlacklisted(): boolean; visit(): boolean; skip(): void; skipKey(key: string): void; stop(): void; setScope(): void; setContext(context?: TraversalContext): this; popContext(): void; pushContext(context: TraversalContext): void; //#endregion //#region ------------------------- removal ------------------------- remove(): void; //#endregion //#region ------------------------- modification ------------------------- /** Insert the provided nodes before the current one. */ insertBefore(nodes: Nodes): NodePaths; /** * Insert the provided nodes after the current one. When inserting nodes after an * expression, ensure that the completion record is correct by pushing the current node. */ insertAfter(nodes: Nodes): NodePaths; /** Update all sibling node paths after `fromIndex` by `incrementBy`. */ updateSiblingKeys(fromIndex: number, incrementBy: number): void; /** * Insert child nodes at the start of the current node. * @param listKey - The key at which the child nodes are stored (usually body). * @param nodes - the nodes to insert. */ unshiftContainer(listKey: ArrayKeys, nodes: Nodes): NodePaths; /** * Insert child nodes at the end of the current node. * @param listKey - The key at which the child nodes are stored (usually body). * @param nodes - the nodes to insert. */ pushContainer(listKey: ArrayKeys, nodes: Nodes): NodePaths; /** Hoist the current node to the highest scope possible and return a UID referencing it. */ hoist(scope: Scope): void; //#endregion //#region ------------------------- family ------------------------- getOpposite(): NodePath; getCompletionRecords(): NodePath[]; getSibling(key: string | number): NodePath; getPrevSibling(): NodePath; getNextSibling(): NodePath; getAllPrevSiblings(): NodePath[]; getAllNextSiblings(): NodePath[]; get(key: K, context?: boolean | TraversalContext): NodePathResult; get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[]; getBindingIdentifiers(duplicates: true): Record; getBindingIdentifiers(duplicates?: false): Record; getBindingIdentifiers(duplicates?: boolean): Record; getOuterBindingIdentifiers(duplicates: true): Record; getOuterBindingIdentifiers(duplicates?: false): Record; getOuterBindingIdentifiers(duplicates?: boolean): Record; getBindingIdentifierPaths(duplicates: true, outerOnly?: boolean): Record>>; getBindingIdentifierPaths(duplicates?: false, outerOnly?: boolean): Record>; getBindingIdentifierPaths( duplicates?: boolean, outerOnly?: boolean, ): Record | Array>>; getOuterBindingIdentifierPaths(duplicates: true): Record>>; getOuterBindingIdentifierPaths(duplicates?: false): Record>; getOuterBindingIdentifierPaths( duplicates?: boolean, outerOnly?: boolean, ): Record | Array>>; //#endregion //#region ------------------------- comments ------------------------- /** Share comments amongst siblings. */ shareCommentsWithSiblings(): void; addComment(type: string, content: string, line?: boolean): void; /** Give node `comments` of the specified `type`. */ addComments(type: string, comments: any[]): void; //#endregion //#region ------------------------- isXXX ------------------------- isAnyTypeAnnotation(props?: object | null): this is NodePath; isArrayExpression(props?: object | null): this is NodePath; isArrayPattern(props?: object | null): this is NodePath; isArrayTypeAnnotation(props?: object | null): this is NodePath; isArrowFunctionExpression(props?: object | null): this is NodePath; isAssignmentExpression(props?: object | null): this is NodePath; isAssignmentPattern(props?: object | null): this is NodePath; isAwaitExpression(props?: object | null): this is NodePath; isBigIntLiteral(props?: object | null): this is NodePath; isBinary(props?: object | null): this is NodePath; isBinaryExpression(props?: object | null): this is NodePath; isBindExpression(props?: object | null): this is NodePath; isBlock(props?: object | null): this is NodePath; isBlockParent(props?: object | null): this is NodePath; isBlockStatement(props?: object | null): this is NodePath; isBooleanLiteral(props?: object | null): this is NodePath; isBooleanLiteralTypeAnnotation(props?: object | null): this is NodePath; isBooleanTypeAnnotation(props?: object | null): this is NodePath; isBreakStatement(props?: object | null): this is NodePath; isCallExpression(props?: object | null): this is NodePath; isCatchClause(props?: object | null): this is NodePath; isClass(props?: object | null): this is NodePath; isClassBody(props?: object | null): this is NodePath; isClassDeclaration(props?: object | null): this is NodePath; isClassExpression(props?: object | null): this is NodePath; isClassImplements(props?: object | null): this is NodePath; isClassMethod(props?: object | null): this is NodePath; isClassPrivateMethod(props?: object | null): this is NodePath; isClassPrivateProperty(props?: object | null): this is NodePath; isClassProperty(props?: object | null): this is NodePath; isCompletionStatement(props?: object | null): this is NodePath; isConditional(props?: object | null): this is NodePath; isConditionalExpression(props?: object | null): this is NodePath; isContinueStatement(props?: object | null): this is NodePath; isDebuggerStatement(props?: object | null): this is NodePath; isDeclaration(props?: object | null): this is NodePath; isDeclareClass(props?: object | null): this is NodePath; isDeclareExportAllDeclaration(props?: object | null): this is NodePath; isDeclareExportDeclaration(props?: object | null): this is NodePath; isDeclareFunction(props?: object | null): this is NodePath; isDeclareInterface(props?: object | null): this is NodePath; isDeclareModule(props?: object | null): this is NodePath; isDeclareModuleExports(props?: object | null): this is NodePath; isDeclareOpaqueType(props?: object | null): this is NodePath; isDeclareTypeAlias(props?: object | null): this is NodePath; isDeclareVariable(props?: object | null): this is NodePath; isDeclaredPredicate(props?: object | null): this is NodePath; isDecorator(props?: object | null): this is NodePath; isDirective(props?: object | null): this is NodePath; isDirectiveLiteral(props?: object | null): this is NodePath; isDoExpression(props?: object | null): this is NodePath; isDoWhileStatement(props?: object | null): this is NodePath; isEmptyStatement(props?: object | null): this is NodePath; isEmptyTypeAnnotation(props?: object | null): this is NodePath; isExistsTypeAnnotation(props?: object | null): this is NodePath; isExportAllDeclaration(props?: object | null): this is NodePath; isExportDeclaration(props?: object | null): this is NodePath; isExportDefaultDeclaration(props?: object | null): this is NodePath; isExportDefaultSpecifier(props?: object | null): this is NodePath; isExportNamedDeclaration(props?: object | null): this is NodePath; isExportNamespaceSpecifier(props?: object | null): this is NodePath; isExportSpecifier(props?: object | null): this is NodePath; isExpression(props?: object | null): this is NodePath; isExpressionStatement(props?: object | null): this is NodePath; isExpressionWrapper(props?: object | null): this is NodePath; isFile(props?: object | null): this is NodePath; isFlow(props?: object | null): this is NodePath; isFlowBaseAnnotation(props?: object | null): this is NodePath; isFlowDeclaration(props?: object | null): this is NodePath; isFlowPredicate(props?: object | null): this is NodePath; isFlowType(props?: object | null): this is NodePath; isFor(props?: object | null): this is NodePath; isForInStatement(props?: object | null): this is NodePath; isForOfStatement(props?: object | null): this is NodePath; isForStatement(props?: object | null): this is NodePath; isForXStatement(props?: object | null): this is NodePath; isFunction(props?: object | null): this is NodePath; isFunctionDeclaration(props?: object | null): this is NodePath; isFunctionExpression(props?: object | null): this is NodePath; isFunctionParent(props?: object | null): this is NodePath; isFunctionTypeAnnotation(props?: object | null): this is NodePath; isFunctionTypeParam(props?: object | null): this is NodePath; isGenericTypeAnnotation(props?: object | null): this is NodePath; isIdentifier(props?: object | null): this is NodePath; isIfStatement(props?: object | null): this is NodePath; isImmutable(props?: object | null): this is NodePath; isImport(props?: object | null): this is NodePath; isImportDeclaration(props?: object | null): this is NodePath; isImportDefaultSpecifier(props?: object | null): this is NodePath; isImportNamespaceSpecifier(props?: object | null): this is NodePath; isImportSpecifier(props?: object | null): this is NodePath; isInferredPredicate(props?: object | null): this is NodePath; isInterfaceDeclaration(props?: object | null): this is NodePath; isInterfaceExtends(props?: object | null): this is NodePath; isInterfaceTypeAnnotation(props?: object | null): this is NodePath; isInterpreterDirective(props?: object | null): this is NodePath; isIntersectionTypeAnnotation(props?: object | null): this is NodePath; isJSX(props?: object | null): this is NodePath; isJSXAttribute(props?: object | null): this is NodePath; isJSXClosingElement(props?: object | null): this is NodePath; isJSXClosingFragment(props?: object | null): this is NodePath; isJSXElement(props?: object | null): this is NodePath; isJSXEmptyExpression(props?: object | null): this is NodePath; isJSXExpressionContainer(props?: object | null): this is NodePath; isJSXFragment(props?: object | null): this is NodePath; isJSXIdentifier(props?: object | null): this is NodePath; isJSXMemberExpression(props?: object | null): this is NodePath; isJSXNamespacedName(props?: object | null): this is NodePath; isJSXOpeningElement(props?: object | null): this is NodePath; isJSXOpeningFragment(props?: object | null): this is NodePath; isJSXSpreadAttribute(props?: object | null): this is NodePath; isJSXSpreadChild(props?: object | null): this is NodePath; isJSXText(props?: object | null): this is NodePath; isLVal(props?: object | null): this is NodePath; isLabeledStatement(props?: object | null): this is NodePath; isLiteral(props?: object | null): this is NodePath; isLogicalExpression(props?: object | null): this is NodePath; isLoop(props?: object | null): this is NodePath; isMemberExpression(props?: object | null): this is NodePath; isMetaProperty(props?: object | null): this is NodePath; isMethod(props?: object | null): this is NodePath; isMixedTypeAnnotation(props?: object | null): this is NodePath; isModuleDeclaration(props?: object | null): this is NodePath; isModuleSpecifier(props?: object | null): this is NodePath; isNewExpression(props?: object | null): this is NodePath; isNoop(props?: object | null): this is NodePath; isNullLiteral(props?: object | null): this is NodePath; isNullLiteralTypeAnnotation(props?: object | null): this is NodePath; isNullableTypeAnnotation(props?: object | null): this is NodePath; /** @deprecated Use `isNumericLiteral` */ isNumberLiteral(props?: object | null): this is NodePath; isNumberLiteralTypeAnnotation(props?: object | null): this is NodePath; isNumberTypeAnnotation(props?: object | null): this is NodePath; isNumericLiteral(props?: object | null): this is NodePath; isObjectExpression(props?: object | null): this is NodePath; isObjectMember(props?: object | null): this is NodePath; isObjectMethod(props?: object | null): this is NodePath; isObjectPattern(props?: object | null): this is NodePath; isObjectProperty(props?: object | null): this is NodePath; isObjectTypeAnnotation(props?: object | null): this is NodePath; isObjectTypeCallProperty(props?: object | null): this is NodePath; isObjectTypeIndexer(props?: object | null): this is NodePath; isObjectTypeInternalSlot(props?: object | null): this is NodePath; isObjectTypeProperty(props?: object | null): this is NodePath; isObjectTypeSpreadProperty(props?: object | null): this is NodePath; isOpaqueType(props?: object | null): this is NodePath; isOptionalCallExpression(props?: object | null): this is NodePath; isOptionalMemberExpression(props?: object | null): this is NodePath; isParenthesizedExpression(props?: object | null): this is NodePath; isPattern(props?: object | null): this is NodePath; isPatternLike(props?: object | null): this is NodePath; isPipelineBareFunction(props?: object | null): this is NodePath; isPipelinePrimaryTopicReference(props?: object | null): this is NodePath; isPipelineTopicExpression(props?: object | null): this is NodePath; isPrivate(props?: object | null): this is NodePath; isPrivateName(props?: object | null): this is NodePath; isProgram(props?: object | null): this is NodePath; isProperty(props?: object | null): this is NodePath; isPureish(props?: object | null): this is NodePath; isQualifiedTypeIdentifier(props?: object | null): this is NodePath; isRegExpLiteral(props?: object | null): this is NodePath; /** @deprecated Use `isRegExpLiteral` */ isRegexLiteral(props?: object | null): this is NodePath; isRestElement(props?: object | null): this is NodePath; /** @deprecated Use `isRestElement` */ isRestProperty(props?: object | null): this is NodePath; isReturnStatement(props?: object | null): this is NodePath; isScopable(props?: object | null): this is NodePath; isSequenceExpression(props?: object | null): this is NodePath; isSpreadElement(props?: object | null): this is NodePath; /** @deprecated Use `isSpreadElement` */ isSpreadProperty(props?: object | null): this is NodePath; isStatement(props?: object | null): this is NodePath; isStringLiteral(props?: object | null): this is NodePath; isStringLiteralTypeAnnotation(props?: object | null): this is NodePath; isStringTypeAnnotation(props?: object | null): this is NodePath; isSuper(props?: object | null): this is NodePath; isSwitchCase(props?: object | null): this is NodePath; isSwitchStatement(props?: object | null): this is NodePath; isTSAnyKeyword(props?: object | null): this is NodePath; isTSArrayType(props?: object | null): this is NodePath; isTSAsExpression(props?: object | null): this is NodePath; isTSBooleanKeyword(props?: object | null): this is NodePath; isTSCallSignatureDeclaration(props?: object | null): this is NodePath; isTSConditionalType(props?: object | null): this is NodePath; isTSConstructSignatureDeclaration(props?: object | null): this is NodePath; isTSConstructorType(props?: object | null): this is NodePath; isTSDeclareFunction(props?: object | null): this is NodePath; isTSDeclareMethod(props?: object | null): this is NodePath; isTSEntityName(props?: object | null): this is NodePath; isTSEnumDeclaration(props?: object | null): this is NodePath; isTSEnumMember(props?: object | null): this is NodePath; isTSExportAssignment(props?: object | null): this is NodePath; isTSExpressionWithTypeArguments(props?: object | null): this is NodePath; isTSExternalModuleReference(props?: object | null): this is NodePath; isTSFunctionType(props?: object | null): this is NodePath; isTSImportEqualsDeclaration(props?: object | null): this is NodePath; isTSImportType(props?: object | null): this is NodePath; isTSIndexSignature(props?: object | null): this is NodePath; isTSIndexedAccessType(props?: object | null): this is NodePath; isTSInferType(props?: object | null): this is NodePath; isTSInterfaceBody(props?: object | null): this is NodePath; isTSInterfaceDeclaration(props?: object | null): this is NodePath; isTSIntersectionType(props?: object | null): this is NodePath; isTSLiteralType(props?: object | null): this is NodePath; isTSMappedType(props?: object | null): this is NodePath; isTSMethodSignature(props?: object | null): this is NodePath; isTSModuleBlock(props?: object | null): this is NodePath; isTSModuleDeclaration(props?: object | null): this is NodePath; isTSNamespaceExportDeclaration(props?: object | null): this is NodePath; isTSNeverKeyword(props?: object | null): this is NodePath; isTSNonNullExpression(props?: object | null): this is NodePath; isTSNullKeyword(props?: object | null): this is NodePath; isTSNumberKeyword(props?: object | null): this is NodePath; isTSObjectKeyword(props?: object | null): this is NodePath; isTSOptionalType(props?: object | null): this is NodePath; isTSParameterProperty(props?: object | null): this is NodePath; isTSParenthesizedType(props?: object | null): this is NodePath; isTSPropertySignature(props?: object | null): this is NodePath; isTSQualifiedName(props?: object | null): this is NodePath; isTSRestType(props?: object | null): this is NodePath; isTSStringKeyword(props?: object | null): this is NodePath; isTSSymbolKeyword(props?: object | null): this is NodePath; isTSThisType(props?: object | null): this is NodePath; isTSTupleType(props?: object | null): this is NodePath; isTSType(props?: object | null): this is NodePath; isTSTypeAliasDeclaration(props?: object | null): this is NodePath; isTSTypeAnnotation(props?: object | null): this is NodePath; isTSTypeAssertion(props?: object | null): this is NodePath; isTSTypeElement(props?: object | null): this is NodePath; isTSTypeLiteral(props?: object | null): this is NodePath; isTSTypeOperator(props?: object | null): this is NodePath; isTSTypeParameter(props?: object | null): this is NodePath; isTSTypeParameterDeclaration(props?: object | null): this is NodePath; isTSTypeParameterInstantiation(props?: object | null): this is NodePath; isTSTypePredicate(props?: object | null): this is NodePath; isTSTypeQuery(props?: object | null): this is NodePath; isTSTypeReference(props?: object | null): this is NodePath; isTSUndefinedKeyword(props?: object | null): this is NodePath; isTSUnionType(props?: object | null): this is NodePath; isTSUnknownKeyword(props?: object | null): this is NodePath; isTSVoidKeyword(props?: object | null): this is NodePath; isTaggedTemplateExpression(props?: object | null): this is NodePath; isTemplateElement(props?: object | null): this is NodePath; isTemplateLiteral(props?: object | null): this is NodePath; isTerminatorless(props?: object | null): this is NodePath; isThisExpression(props?: object | null): this is NodePath; isThisTypeAnnotation(props?: object | null): this is NodePath; isThrowStatement(props?: object | null): this is NodePath; isTryStatement(props?: object | null): this is NodePath; isTupleTypeAnnotation(props?: object | null): this is NodePath; isTypeAlias(props?: object | null): this is NodePath; isTypeAnnotation(props?: object | null): this is NodePath; isTypeCastExpression(props?: object | null): this is NodePath; isTypeParameter(props?: object | null): this is NodePath; isTypeParameterDeclaration(props?: object | null): this is NodePath; isTypeParameterInstantiation(props?: object | null): this is NodePath; isTypeofTypeAnnotation(props?: object | null): this is NodePath; isUnaryExpression(props?: object | null): this is NodePath; isUnaryLike(props?: object | null): this is NodePath; isUnionTypeAnnotation(props?: object | null): this is NodePath; isUpdateExpression(props?: object | null): this is NodePath; isUserWhitespacable(props?: object | null): this is NodePath; isVariableDeclaration(props?: object | null): this is NodePath; isVariableDeclarator(props?: object | null): this is NodePath; isVariance(props?: object | null): this is NodePath; isVoidTypeAnnotation(props?: object | null): this is NodePath; isWhile(props?: object | null): this is NodePath; isWhileStatement(props?: object | null): this is NodePath; isWithStatement(props?: object | null): this is NodePath; isYieldExpression(props?: object | null): this is NodePath; isBindingIdentifier(props?: object | null): this is NodePath; isBlockScoped( props?: object | null, ): this is NodePath; isGenerated(props?: object | null): boolean; isPure(props?: object | null): boolean; isReferenced(props?: object | null): boolean; isReferencedIdentifier(props?: object | null): this is NodePath; isReferencedMemberExpression(props?: object | null): this is NodePath; isScope(props?: object | null): this is NodePath; isUser(props?: object | null): boolean; isVar(props?: object | null): this is NodePath; //#endregion //#region ------------------------- assertXXX ------------------------- assertAnyTypeAnnotation(props?: object | null): void; assertArrayExpression(props?: object | null): void; assertArrayPattern(props?: object | null): void; assertArrayTypeAnnotation(props?: object | null): void; assertArrowFunctionExpression(props?: object | null): void; assertAssignmentExpression(props?: object | null): void; assertAssignmentPattern(props?: object | null): void; assertAwaitExpression(props?: object | null): void; assertBigIntLiteral(props?: object | null): void; assertBinary(props?: object | null): void; assertBinaryExpression(props?: object | null): void; assertBindExpression(props?: object | null): void; assertBlock(props?: object | null): void; assertBlockParent(props?: object | null): void; assertBlockStatement(props?: object | null): void; assertBooleanLiteral(props?: object | null): void; assertBooleanLiteralTypeAnnotation(props?: object | null): void; assertBooleanTypeAnnotation(props?: object | null): void; assertBreakStatement(props?: object | null): void; assertCallExpression(props?: object | null): void; assertCatchClause(props?: object | null): void; assertClass(props?: object | null): void; assertClassBody(props?: object | null): void; assertClassDeclaration(props?: object | null): void; assertClassExpression(props?: object | null): void; assertClassImplements(props?: object | null): void; assertClassMethod(props?: object | null): void; assertClassPrivateMethod(props?: object | null): void; assertClassPrivateProperty(props?: object | null): void; assertClassProperty(props?: object | null): void; assertCompletionStatement(props?: object | null): void; assertConditional(props?: object | null): void; assertConditionalExpression(props?: object | null): void; assertContinueStatement(props?: object | null): void; assertDebuggerStatement(props?: object | null): void; assertDeclaration(props?: object | null): void; assertDeclareClass(props?: object | null): void; assertDeclareExportAllDeclaration(props?: object | null): void; assertDeclareExportDeclaration(props?: object | null): void; assertDeclareFunction(props?: object | null): void; assertDeclareInterface(props?: object | null): void; assertDeclareModule(props?: object | null): void; assertDeclareModuleExports(props?: object | null): void; assertDeclareOpaqueType(props?: object | null): void; assertDeclareTypeAlias(props?: object | null): void; assertDeclareVariable(props?: object | null): void; assertDeclaredPredicate(props?: object | null): void; assertDecorator(props?: object | null): void; assertDirective(props?: object | null): void; assertDirectiveLiteral(props?: object | null): void; assertDoExpression(props?: object | null): void; assertDoWhileStatement(props?: object | null): void; assertEmptyStatement(props?: object | null): void; assertEmptyTypeAnnotation(props?: object | null): void; assertExistsTypeAnnotation(props?: object | null): void; assertExportAllDeclaration(props?: object | null): void; assertExportDeclaration(props?: object | null): void; assertExportDefaultDeclaration(props?: object | null): void; assertExportDefaultSpecifier(props?: object | null): void; assertExportNamedDeclaration(props?: object | null): void; assertExportNamespaceSpecifier(props?: object | null): void; assertExportSpecifier(props?: object | null): void; assertExpression(props?: object | null): void; assertExpressionStatement(props?: object | null): void; assertExpressionWrapper(props?: object | null): void; assertFile(props?: object | null): void; assertFlow(props?: object | null): void; assertFlowBaseAnnotation(props?: object | null): void; assertFlowDeclaration(props?: object | null): void; assertFlowPredicate(props?: object | null): void; assertFlowType(props?: object | null): void; assertFor(props?: object | null): void; assertForInStatement(props?: object | null): void; assertForOfStatement(props?: object | null): void; assertForStatement(props?: object | null): void; assertForXStatement(props?: object | null): void; assertFunction(props?: object | null): void; assertFunctionDeclaration(props?: object | null): void; assertFunctionExpression(props?: object | null): void; assertFunctionParent(props?: object | null): void; assertFunctionTypeAnnotation(props?: object | null): void; assertFunctionTypeParam(props?: object | null): void; assertGenericTypeAnnotation(props?: object | null): void; assertIdentifier(props?: object | null): void; assertIfStatement(props?: object | null): void; assertImmutable(props?: object | null): void; assertImport(props?: object | null): void; assertImportDeclaration(props?: object | null): void; assertImportDefaultSpecifier(props?: object | null): void; assertImportNamespaceSpecifier(props?: object | null): void; assertImportSpecifier(props?: object | null): void; assertInferredPredicate(props?: object | null): void; assertInterfaceDeclaration(props?: object | null): void; assertInterfaceExtends(props?: object | null): void; assertInterfaceTypeAnnotation(props?: object | null): void; assertInterpreterDirective(props?: object | null): void; assertIntersectionTypeAnnotation(props?: object | null): void; assertJSX(props?: object | null): void; assertJSXAttribute(props?: object | null): void; assertJSXClosingElement(props?: object | null): void; assertJSXClosingFragment(props?: object | null): void; assertJSXElement(props?: object | null): void; assertJSXEmptyExpression(props?: object | null): void; assertJSXExpressionContainer(props?: object | null): void; assertJSXFragment(props?: object | null): void; assertJSXIdentifier(props?: object | null): void; assertJSXMemberExpression(props?: object | null): void; assertJSXNamespacedName(props?: object | null): void; assertJSXOpeningElement(props?: object | null): void; assertJSXOpeningFragment(props?: object | null): void; assertJSXSpreadAttribute(props?: object | null): void; assertJSXSpreadChild(props?: object | null): void; assertJSXText(props?: object | null): void; assertLVal(props?: object | null): void; assertLabeledStatement(props?: object | null): void; assertLiteral(props?: object | null): void; assertLogicalExpression(props?: object | null): void; assertLoop(props?: object | null): void; assertMemberExpression(props?: object | null): void; assertMetaProperty(props?: object | null): void; assertMethod(props?: object | null): void; assertMixedTypeAnnotation(props?: object | null): void; assertModuleDeclaration(props?: object | null): void; assertModuleSpecifier(props?: object | null): void; assertNewExpression(props?: object | null): void; assertNoop(props?: object | null): void; assertNullLiteral(props?: object | null): void; assertNullLiteralTypeAnnotation(props?: object | null): void; assertNullableTypeAnnotation(props?: object | null): void; /** @deprecated Use `assertNumericLiteral` */ assertNumberLiteral(props?: object | null): void; assertNumberLiteralTypeAnnotation(props?: object | null): void; assertNumberTypeAnnotation(props?: object | null): void; assertNumericLiteral(props?: object | null): void; assertObjectExpression(props?: object | null): void; assertObjectMember(props?: object | null): void; assertObjectMethod(props?: object | null): void; assertObjectPattern(props?: object | null): void; assertObjectProperty(props?: object | null): void; assertObjectTypeAnnotation(props?: object | null): void; assertObjectTypeCallProperty(props?: object | null): void; assertObjectTypeIndexer(props?: object | null): void; assertObjectTypeInternalSlot(props?: object | null): void; assertObjectTypeProperty(props?: object | null): void; assertObjectTypeSpreadProperty(props?: object | null): void; assertOpaqueType(props?: object | null): void; assertOptionalCallExpression(props?: object | null): void; assertOptionalMemberExpression(props?: object | null): void; assertParenthesizedExpression(props?: object | null): void; assertPattern(props?: object | null): void; assertPatternLike(props?: object | null): void; assertPipelineBareFunction(props?: object | null): void; assertPipelinePrimaryTopicReference(props?: object | null): void; assertPipelineTopicExpression(props?: object | null): void; assertPrivate(props?: object | null): void; assertPrivateName(props?: object | null): void; assertProgram(props?: object | null): void; assertProperty(props?: object | null): void; assertPureish(props?: object | null): void; assertQualifiedTypeIdentifier(props?: object | null): void; assertRegExpLiteral(props?: object | null): void; /** @deprecated Use `assertRegExpLiteral` */ assertRegexLiteral(props?: object | null): void; assertRestElement(props?: object | null): void; /** @deprecated Use `assertRestElement` */ assertRestProperty(props?: object | null): void; assertReturnStatement(props?: object | null): void; assertScopable(props?: object | null): void; assertSequenceExpression(props?: object | null): void; assertSpreadElement(props?: object | null): void; /** @deprecated Use `assertSpreadElement` */ assertSpreadProperty(props?: object | null): void; assertStatement(props?: object | null): void; assertStringLiteral(props?: object | null): void; assertStringLiteralTypeAnnotation(props?: object | null): void; assertStringTypeAnnotation(props?: object | null): void; assertSuper(props?: object | null): void; assertSwitchCase(props?: object | null): void; assertSwitchStatement(props?: object | null): void; assertTSAnyKeyword(props?: object | null): void; assertTSArrayType(props?: object | null): void; assertTSAsExpression(props?: object | null): void; assertTSBooleanKeyword(props?: object | null): void; assertTSCallSignatureDeclaration(props?: object | null): void; assertTSConditionalType(props?: object | null): void; assertTSConstructSignatureDeclaration(props?: object | null): void; assertTSConstructorType(props?: object | null): void; assertTSDeclareFunction(props?: object | null): void; assertTSDeclareMethod(props?: object | null): void; assertTSEntityName(props?: object | null): void; assertTSEnumDeclaration(props?: object | null): void; assertTSEnumMember(props?: object | null): void; assertTSExportAssignment(props?: object | null): void; assertTSExpressionWithTypeArguments(props?: object | null): void; assertTSExternalModuleReference(props?: object | null): void; assertTSFunctionType(props?: object | null): void; assertTSImportEqualsDeclaration(props?: object | null): void; assertTSImportType(props?: object | null): void; assertTSIndexSignature(props?: object | null): void; assertTSIndexedAccessType(props?: object | null): void; assertTSInferType(props?: object | null): void; assertTSInterfaceBody(props?: object | null): void; assertTSInterfaceDeclaration(props?: object | null): void; assertTSIntersectionType(props?: object | null): void; assertTSLiteralType(props?: object | null): void; assertTSMappedType(props?: object | null): void; assertTSMethodSignature(props?: object | null): void; assertTSModuleBlock(props?: object | null): void; assertTSModuleDeclaration(props?: object | null): void; assertTSNamespaceExportDeclaration(props?: object | null): void; assertTSNeverKeyword(props?: object | null): void; assertTSNonNullExpression(props?: object | null): void; assertTSNullKeyword(props?: object | null): void; assertTSNumberKeyword(props?: object | null): void; assertTSObjectKeyword(props?: object | null): void; assertTSOptionalType(props?: object | null): void; assertTSParameterProperty(props?: object | null): void; assertTSParenthesizedType(props?: object | null): void; assertTSPropertySignature(props?: object | null): void; assertTSQualifiedName(props?: object | null): void; assertTSRestType(props?: object | null): void; assertTSStringKeyword(props?: object | null): void; assertTSSymbolKeyword(props?: object | null): void; assertTSThisType(props?: object | null): void; assertTSTupleType(props?: object | null): void; assertTSType(props?: object | null): void; assertTSTypeAliasDeclaration(props?: object | null): void; assertTSTypeAnnotation(props?: object | null): void; assertTSTypeAssertion(props?: object | null): void; assertTSTypeElement(props?: object | null): void; assertTSTypeLiteral(props?: object | null): void; assertTSTypeOperator(props?: object | null): void; assertTSTypeParameter(props?: object | null): void; assertTSTypeParameterDeclaration(props?: object | null): void; assertTSTypeParameterInstantiation(props?: object | null): void; assertTSTypePredicate(props?: object | null): void; assertTSTypeQuery(props?: object | null): void; assertTSTypeReference(props?: object | null): void; assertTSUndefinedKeyword(props?: object | null): void; assertTSUnionType(props?: object | null): void; assertTSUnknownKeyword(props?: object | null): void; assertTSVoidKeyword(props?: object | null): void; assertTaggedTemplateExpression(props?: object | null): void; assertTemplateElement(props?: object | null): void; assertTemplateLiteral(props?: object | null): void; assertTerminatorless(props?: object | null): void; assertThisExpression(props?: object | null): void; assertThisTypeAnnotation(props?: object | null): void; assertThrowStatement(props?: object | null): void; assertTryStatement(props?: object | null): void; assertTupleTypeAnnotation(props?: object | null): void; assertTypeAlias(props?: object | null): void; assertTypeAnnotation(props?: object | null): void; assertTypeCastExpression(props?: object | null): void; assertTypeParameter(props?: object | null): void; assertTypeParameterDeclaration(props?: object | null): void; assertTypeParameterInstantiation(props?: object | null): void; assertTypeofTypeAnnotation(props?: object | null): void; assertUnaryExpression(props?: object | null): void; assertUnaryLike(props?: object | null): void; assertUnionTypeAnnotation(props?: object | null): void; assertUpdateExpression(props?: object | null): void; assertUserWhitespacable(props?: object | null): void; assertVariableDeclaration(props?: object | null): void; assertVariableDeclarator(props?: object | null): void; assertVariance(props?: object | null): void; assertVoidTypeAnnotation(props?: object | null): void; assertWhile(props?: object | null): void; assertWhileStatement(props?: object | null): void; assertWithStatement(props?: object | null): void; assertYieldExpression(props?: object | null): void; assertBindingIdentifier(props?: object | null): void; assertBlockScoped(props?: object | null): void; assertGenerated(props?: object | null): void; assertPure(props?: object | null): void; assertReferenced(props?: object | null): void; assertReferencedIdentifier(props?: object | null): void; assertReferencedMemberExpression(props?: object | null): void; assertScope(props?: object | null): void; assertUser(props?: object | null): void; assertVar(props?: object | null): void; //#endregion } export interface HubInterface { getCode(): string | undefined; getScope(): Scope | undefined; addHelper(name: string): any; buildError(node: Node, msg: string, Error: new (message?: string) => E): E; } export class Hub implements HubInterface { constructor(); getCode(): string | undefined; getScope(): Scope | undefined; addHelper(name: string): any; buildError(node: Node, msg: string, Constructor: new (message?: string) => E): E; } export interface TraversalContext { parentPath: NodePath; scope: Scope; state: any; opts: any; } export type NodePathResult = | (Extract extends never ? never : NodePath>) | (T extends Array ? Array> : never);