From a6e9b46ee3923ba8cdd12596fe0b1a71f298bb58 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Tue, 8 Sep 2020 22:56:48 +0200 Subject: [PATCH] =?UTF-8?q?fix(@babel/traverse):=20Update=C2=A0to=C2=A0v7.?= =?UTF-8?q?0=20stable=C2=A0release=20(#47183)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(@babel/traverse): Update to v7.0 stable release * feat(@babel/traverse): Add top‑level `visitors` export --- .../babel__traverse/babel__traverse-tests.ts | 93 +- types/babel__traverse/index.d.ts | 1088 +++++++++++------ types/babel__traverse/tslint.json | 7 +- 3 files changed, 770 insertions(+), 418 deletions(-) diff --git a/types/babel__traverse/babel__traverse-tests.ts b/types/babel__traverse/babel__traverse-tests.ts index ebddb01f505dd7..313ad1a5223294 100644 --- a/types/babel__traverse/babel__traverse-tests.ts +++ b/types/babel__traverse/babel__traverse-tests.ts @@ -1,14 +1,16 @@ -import traverse, { Visitor, NodePath, Hub } from '@babel/traverse'; +import traverse, { Hub, NodePath, Visitor, visitors } from '@babel/traverse'; import * as t from '@babel/types'; // Examples from: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md const MyVisitor: Visitor = { Identifier: { enter(path) { + path.type; // $ExpectType "Identifier" const x: NodePath = path; console.log('Entered!'); }, exit(path) { + path.type; // $ExpectType "Identifier" const x: NodePath = path; console.log('Exited!'); }, @@ -17,6 +19,7 @@ const MyVisitor: Visitor = { const MyVisitor2: Visitor = { Identifier(path) { + path.type; // $ExpectType "Identifier" console.log('Visiting: ' + path.node.name); }, }; @@ -26,6 +29,10 @@ declare const ast: t.Node; traverse(ast, { enter(path) { + let actualType = path.type; + const expectedType: t.Node['type'] = actualType; + actualType = ast.type; + const node = path.node; if (t.isIdentifier(node) && node.name === 'n') { node.name = 'x'; @@ -37,27 +44,31 @@ traverse(ast, { const v1: Visitor = { BinaryExpression(path) { + path.type; // $ExpectType "BinaryExpression" + if (t.isIdentifier(path.node.left)) { // ... } - path.replaceWith(t.binaryExpression('**', path.node.left, t.numericLiteral(2))) as [ - NodePath, - ]; + // $ExpectType [NodePath] + path.replaceWith(t.binaryExpression('**', path.node.left, t.numericLiteral(2))); path.parentPath.replaceWith( t.expressionStatement(t.stringLiteral("Anyway the wind blows, doesn't really matter to me, to me.")), ); - path.replaceInline(t.binaryExpression('**', path.node.left, t.numericLiteral(2))) as [ - NodePath, - ]; + // $ExpectType [NodePath] + path.replaceInline(t.binaryExpression('**', path.node.left, t.numericLiteral(2))); + // $ExpectType [NodePath] path.replaceWithSourceString('3 * 4') as [NodePath]; + // $ExpectType [NodePath, NodePath] path.replaceInline([ t.binaryExpression('**', path.node.left, t.numericLiteral(2)), t.expressionStatement(t.stringLiteral("Anyway the wind blows, doesn't really matter to me, to me.")), - ]) as [NodePath, NodePath]; + ] as const); path.parentPath.remove(); }, Identifier(path) { + path.type; // $ExpectType "Identifier" + if (path.isReferencedIdentifier()) { // ... } @@ -67,14 +78,19 @@ const v1: Visitor = { }, ReturnStatement(path) { + path.type; // $ExpectType "ReturnStatement" + + // $ExpectType [NodePath, NodePath, NodePath] path.replaceWithMultiple([ t.expressionStatement(t.stringLiteral('Is this the real life?')), t.expressionStatement(t.stringLiteral('Is this just fantasy?')), t.expressionStatement(t.stringLiteral('(Enjoy singing the rest of the song in your head)')), - ]) as [NodePath, NodePath, NodePath]; + ] as const); }, FunctionDeclaration(path, state) { + path.type; // $ExpectType "FunctionDeclaration" + path.replaceWithSourceString(`function add(a, b) { return a + b; }`); @@ -114,6 +130,8 @@ const v1: Visitor = { path.unshiftContainer('returnType', t.stringLiteral('hello')); }, ExportDefaultDeclaration(path) { + path.type; // $ExpectType "ExportDefaultDeclaration" + { const [stringPath, booleanPath] = path.replaceWithMultiple([ t.stringLiteral('hello'), @@ -146,6 +164,8 @@ const v1: Visitor = { } }, Program(path) { + path.type; // $ExpectType "Program" + { const [newPath] = path.unshiftContainer('body', t.stringLiteral('hello')); // $ExpectType NodePath @@ -202,6 +222,8 @@ const v1: Visitor = { // Binding.kind const BindingKindTest: Visitor = { Identifier(path) { + path.type; // $ExpectType "Identifier" + const kind = path.scope.getBinding('str')!.kind; kind === 'module'; kind === 'const'; @@ -218,18 +240,28 @@ interface SomeVisitorState { const VisitorStateTest: Visitor = { enter(path, state) { + let actualType = path.type; + const expectedType: t.Node['type'] = actualType; + actualType = ast.type; + // $ExpectType SomeVisitorState state; // $ExpectType SomeVisitorState this; }, exit(path, state) { + let actualType = path.type; + const expectedType: t.Node['type'] = actualType; + actualType = ast.type; + // $ExpectType SomeVisitorState state; // $ExpectType SomeVisitorState this; }, Identifier(path, state) { + path.type; // $ExpectType "Identifier" + // $ExpectType SomeVisitorState state; // $ExpectType SomeVisitorState @@ -237,12 +269,16 @@ const VisitorStateTest: Visitor = { }, FunctionDeclaration: { enter(path, state) { + path.type; // $ExpectType "FunctionDeclaration" + // $ExpectType SomeVisitorState state; // $ExpectType SomeVisitorState this; }, exit(path, state) { + path.type; // $ExpectType "FunctionDeclaration" + // $ExpectType SomeVisitorState state; // $ExpectType SomeVisitorState @@ -258,8 +294,43 @@ const VisitorAliasTest: Visitor = { Expression() {}, }; -const hub = new Hub('file', { options: '' }); +const hub = new Hub(); // $ExpectType string | undefined hub.getCode(); -traverse.visitors.merge([{ Expression(path) { } }, { Expression(path) { } }]); +declare const astExpression: t.Expression; + +traverse.visitors; // $ExpectType typeof visitors + +// $ExpectType Visitor +visitors.merge([ + { + Expression(path) { + let actualType = path.type; + const expectedType: t.Expression['type'] = actualType; + actualType = astExpression.type; + }, + }, + { + Expression(path) { + let actualType = path.type; + const expectedType: t.Expression['type'] = actualType; + actualType = astExpression.type; + }, + }, +]); + +function testNullishPath( + optionalPath: NodePath, + nullPath: NodePath, + undefinedPath: NodePath, + unknownPath: NodePath, +) { + nullPath.type; // $ExpectType undefined + undefinedPath.type; // $ExpectType undefined + unknownPath.type; // $ExpectType string | undefined + + let actualType = optionalPath.type; + const expectedType: t.Node['type'] | undefined = actualType; + actualType = expectedType; +} diff --git a/types/babel__traverse/index.d.ts b/types/babel__traverse/index.d.ts index 9e98baf8d065c9..827bae1daa263f 100644 --- a/types/babel__traverse/index.d.ts +++ b/types/babel__traverse/index.d.ts @@ -1,39 +1,63 @@ // Type definitions for @babel/traverse 7.0 -// Project: https://github.com/babel/babel/tree/master/packages/babel-traverse, https://babeljs.io +// 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 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Minimum TypeScript Version: 3.4 import * as t from '@babel/types'; - -export type Node = t.Node; +export import Node = t.Node; declare const traverse: { ( - parent: Node | Node[], + parent: Node | Node[] | null | undefined, opts: TraverseOptions, scope: Scope | undefined, state: S, parentPath?: NodePath, ): void; ( - parent: Node | Node[], - opts: TraverseOptions, + parent: Node | Node[] | null | undefined, + opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath, ): void; - visitors: { - merge: (visitors: Visitor[]) => Visitor - } + 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 { @@ -49,7 +73,7 @@ export class Scope { block: Node; parentBlock: Node; parent: Scope; - hub: Hub; + hub: HubInterface; bindings: { [name: string]: Binding }; /** Traverse node with current scope and path. */ @@ -176,16 +200,20 @@ export type Visitor = VisitNodeObject & [K in keyof t.Aliases]?: VisitNode; }; -export type VisitNode = VisitNodeFunction | VisitNodeObject; +export type VisitNode = VisitNodeFunction | VisitNodeObject; -export type VisitNodeFunction = (this: S, path: NodePath

, state: S) => void; +export type VisitNodeFunction = (this: S, path: NodePath

, state: S) => void; -export interface VisitNodeObject { +export interface VisitNodeObject { enter?: VisitNodeFunction; exit?: VisitNodeFunction; } -export type NodePaths = T extends Node[] ? { [K in keyof T]: NodePath } : [NodePath]; +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); @@ -208,7 +236,7 @@ export class NodePath { key: string | number; node: T; scope: Scope; - type: T extends undefined | null ? string | null : string; + type: T extends null | undefined ? undefined : T extends Node ? T['type'] : string | undefined; typeAnnotation: object; getScope(scope: Scope): Scope; @@ -229,20 +257,36 @@ export class NodePath { // Example: https://github.com/babel/babel/blob/63204ae51e020d84a5b246312f5eeb4d981ab952/packages/babel-traverse/src/path/modification.js#L83 debug(buildMessage: () => string): void; - // ------------------------- ancestry ------------------------- + static get(opts: { + hub: HubInterface; + parentPath: NodePath | null; + parent: Node; + container: C; + listKey?: string; + key: K; + }): NodePath; + + //#region ------------------------- ancestry ------------------------- /** - * Call the provided `callback` with the `NodePath`s of all the parents. - * When the `callback` returns a truthy value, we return that node path. + * 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; + findParent(callback: (path: NodePath) => boolean): NodePath | null; - find(callback: (path: NodePath) => boolean): NodePath; + /** + * 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; + getFunctionParent(): NodePath | null; /** Walk up the tree until we hit a parent node path in a list. */ - getStatementParent(): NodePath; + getStatementParent(): NodePath | null; /** * Get the deepest common ancestor and then from it, get the earliest relationship path @@ -251,7 +295,7 @@ export class NodePath { * Earliest is defined as being "before" all the other nodes in terms of list container * position and visiting key. */ - getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath[]; + getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath; /** Get the earliest path in the tree where the provided `paths` intersect. */ getDeepestCommonAncestorFrom( @@ -264,11 +308,22 @@ export class NodePath { * * NOTE: The current node path is included in this. */ - getAncestry(): NodePath[]; + 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 - // ------------------------- inference ------------------------- + //#region ------------------------- inference ------------------------- /** Infer the type of the current `NodePath`. */ getTypeAnnotation(): t.FlowType; @@ -279,8 +334,9 @@ export class NodePath { baseTypeStrictlyMatches(right: NodePath): boolean; isGenericType(genericName: string): boolean; + //#endregion - // ------------------------- replacement ------------------------- + //#region ------------------------- replacement ------------------------- /** * Replace a node with an array of multiple. This method performs the following steps: * @@ -288,7 +344,7 @@ export class NodePath { * - Insert the provided nodes after the current node. * - Remove the current node. */ - replaceWithMultiple(nodes: Nodes): NodePaths; + replaceWithMultiple(nodes: Nodes): NodePaths; /** * Parse a string as an expression and replace the current node with the result. @@ -307,11 +363,12 @@ export class NodePath { * into expressions. This method retains completion records which is * extremely important to retain original semantics. */ - replaceExpressionWithStatements(nodes: Nodes): NodePaths; + replaceExpressionWithStatements(nodes: Nodes): NodePaths; - replaceInline(nodes: Nodes): NodePaths; + replaceInline(nodes: Nodes): NodePaths; + //#endregion - // ------------------------- evaluation ------------------------- + //#region ------------------------- evaluation ------------------------- /** * Walk the input `node` and statically evaluate if it's truthy. * @@ -336,8 +393,9 @@ export class NodePath { * t.evaluate(parse("foo + foo")) // { confident: false, value: undefined } */ evaluate(): { confident: boolean; value: any }; + //#endregion - // ------------------------- introspection ------------------------- + //#region ------------------------- introspection ------------------------- /** * Match the current node if it matches the provided `pattern`. * @@ -406,8 +464,9 @@ export class NodePath { /** Check if the current path will maybe execute before another path */ willIMaybeExecuteBefore(path: NodePath): boolean; + //#endregion - // ------------------------- context ------------------------- + //#region ------------------------- context ------------------------- call(key: string): boolean; isBlacklisted(): boolean; @@ -427,19 +486,21 @@ export class NodePath { popContext(): void; pushContext(context: TraversalContext): void; + //#endregion - // ------------------------- removal ------------------------- + //#region ------------------------- removal ------------------------- remove(): void; + //#endregion - // ------------------------- modification ------------------------- + //#region ------------------------- modification ------------------------- /** Insert the provided nodes before the current one. */ - insertBefore(nodes: Nodes): NodePaths; + 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; + insertAfter(nodes: Nodes): NodePaths; /** Update all sibling node paths after `fromIndex` by `incrementBy`. */ updateSiblingKeys(fromIndex: number, incrementBy: number): void; @@ -449,19 +510,20 @@ export class NodePath { * @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; + 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; + 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 - // ------------------------- family ------------------------- + //#region ------------------------- family ------------------------- getOpposite(): NodePath; getCompletionRecords(): NodePath[]; @@ -483,8 +545,9 @@ export class NodePath { getBindingIdentifiers(duplicates?: boolean): Node[]; getOuterBindingIdentifiers(duplicates?: boolean): Node[]; + //#endregion - // ------------------------- comments ------------------------- + //#region ------------------------- comments ------------------------- /** Share comments amongst siblings. */ shareCommentsWithSiblings(): void; @@ -492,379 +555,602 @@ export class NodePath { /** Give node `comments` of the specified `type`. */ addComments(type: string, comments: any[]): void; - - // ------------------------- isXXX ------------------------- - isArrayExpression(opts?: object): this is NodePath; - isAssignmentExpression(opts?: object): this is NodePath; - isBinaryExpression(opts?: object): this is NodePath; - isDirective(opts?: object): this is NodePath; - isDirectiveLiteral(opts?: object): this is NodePath; - isBlockStatement(opts?: object): this is NodePath; - isBreakStatement(opts?: object): this is NodePath; - isCallExpression(opts?: object): this is NodePath; - isCatchClause(opts?: object): this is NodePath; - isConditionalExpression(opts?: object): this is NodePath; - isContinueStatement(opts?: object): this is NodePath; - isDebuggerStatement(opts?: object): this is NodePath; - isDoWhileStatement(opts?: object): this is NodePath; - isEmptyStatement(opts?: object): this is NodePath; - isExpressionStatement(opts?: object): this is NodePath; - isFile(opts?: object): this is NodePath; - isForInStatement(opts?: object): this is NodePath; - isForStatement(opts?: object): this is NodePath; - isFunctionDeclaration(opts?: object): this is NodePath; - isFunctionExpression(opts?: object): this is NodePath; - isIdentifier(opts?: object): this is NodePath; - isIfStatement(opts?: object): this is NodePath; - isLabeledStatement(opts?: object): this is NodePath; - isStringLiteral(opts?: object): this is NodePath; - isNumericLiteral(opts?: object): this is NodePath; - isNullLiteral(opts?: object): this is NodePath; - isBooleanLiteral(opts?: object): this is NodePath; - isRegExpLiteral(opts?: object): this is NodePath; - isLogicalExpression(opts?: object): this is NodePath; - isMemberExpression(opts?: object): this is NodePath; - isNewExpression(opts?: object): this is NodePath; - isProgram(opts?: object): this is NodePath; - isObjectExpression(opts?: object): this is NodePath; - isObjectMethod(opts?: object): this is NodePath; - isObjectProperty(opts?: object): this is NodePath; - isRestElement(opts?: object): this is NodePath; - isReturnStatement(opts?: object): this is NodePath; - isSequenceExpression(opts?: object): this is NodePath; - isSwitchCase(opts?: object): this is NodePath; - isSwitchStatement(opts?: object): this is NodePath; - isThisExpression(opts?: object): this is NodePath; - isThrowStatement(opts?: object): this is NodePath; - isTryStatement(opts?: object): this is NodePath; - isUnaryExpression(opts?: object): this is NodePath; - isUpdateExpression(opts?: object): this is NodePath; - isVariableDeclaration(opts?: object): this is NodePath; - isVariableDeclarator(opts?: object): this is NodePath; - isWhileStatement(opts?: object): this is NodePath; - isWithStatement(opts?: object): this is NodePath; - isAssignmentPattern(opts?: object): this is NodePath; - isArrayPattern(opts?: object): this is NodePath; - isArrowFunctionExpression(opts?: object): this is NodePath; - isClassBody(opts?: object): this is NodePath; - isClassDeclaration(opts?: object): this is NodePath; - isClassExpression(opts?: object): this is NodePath; - isExportAllDeclaration(opts?: object): this is NodePath; - isExportDefaultDeclaration(opts?: object): this is NodePath; - isExportNamedDeclaration(opts?: object): this is NodePath; - isExportSpecifier(opts?: object): this is NodePath; - isForOfStatement(opts?: object): this is NodePath; - isImportDeclaration(opts?: object): this is NodePath; - isImportDefaultSpecifier(opts?: object): this is NodePath; - isImportNamespaceSpecifier(opts?: object): this is NodePath; - isImportSpecifier(opts?: object): this is NodePath; - isMetaProperty(opts?: object): this is NodePath; - isClassMethod(opts?: object): this is NodePath; - isObjectPattern(opts?: object): this is NodePath; - isSpreadElement(opts?: object): this is NodePath; - isSuper(opts?: object): this is NodePath; - isTaggedTemplateExpression(opts?: object): this is NodePath; - isTemplateElement(opts?: object): this is NodePath; - isTemplateLiteral(opts?: object): this is NodePath; - isYieldExpression(opts?: object): this is NodePath; - isAnyTypeAnnotation(opts?: object): this is NodePath; - isArrayTypeAnnotation(opts?: object): this is NodePath; - isBooleanTypeAnnotation(opts?: object): this is NodePath; - isBooleanLiteralTypeAnnotation(opts?: object): this is NodePath; - isNullLiteralTypeAnnotation(opts?: object): this is NodePath; - isClassImplements(opts?: object): this is NodePath; - isClassProperty(opts?: object): this is NodePath; - isDeclareClass(opts?: object): this is NodePath; - isDeclareFunction(opts?: object): this is NodePath; - isDeclareInterface(opts?: object): this is NodePath; - isDeclareModule(opts?: object): this is NodePath; - isDeclareTypeAlias(opts?: object): this is NodePath; - isDeclareVariable(opts?: object): this is NodePath; - isFunctionTypeAnnotation(opts?: object): this is NodePath; - isFunctionTypeParam(opts?: object): this is NodePath; - isGenericTypeAnnotation(opts?: object): this is NodePath; - isInterfaceExtends(opts?: object): this is NodePath; - isInterfaceDeclaration(opts?: object): this is NodePath; - isIntersectionTypeAnnotation(opts?: object): this is NodePath; - isMixedTypeAnnotation(opts?: object): this is NodePath; - isNullableTypeAnnotation(opts?: object): this is NodePath; - isNumberTypeAnnotation(opts?: object): this is NodePath; - isStringLiteralTypeAnnotation(opts?: object): this is NodePath; - isStringTypeAnnotation(opts?: object): this is NodePath; - isThisTypeAnnotation(opts?: object): this is NodePath; - isTupleTypeAnnotation(opts?: object): this is NodePath; - isTypeofTypeAnnotation(opts?: object): this is NodePath; - isTypeAlias(opts?: object): this is NodePath; - isTypeAnnotation(opts?: object): this is NodePath; - isTypeCastExpression(opts?: object): this is NodePath; - isTypeParameterDeclaration(opts?: object): this is NodePath; - isTypeParameterInstantiation(opts?: object): this is NodePath; - isObjectTypeAnnotation(opts?: object): this is NodePath; - isObjectTypeCallProperty(opts?: object): this is NodePath; - isObjectTypeIndexer(opts?: object): this is NodePath; - isObjectTypeProperty(opts?: object): this is NodePath; - isQualifiedTypeIdentifier(opts?: object): this is NodePath; - isUnionTypeAnnotation(opts?: object): this is NodePath; - isVoidTypeAnnotation(opts?: object): this is NodePath; - isJSXAttribute(opts?: object): this is NodePath; - isJSXClosingElement(opts?: object): this is NodePath; - isJSXElement(opts?: object): this is NodePath; - isJSXEmptyExpression(opts?: object): this is NodePath; - isJSXExpressionContainer(opts?: object): this is NodePath; - isJSXIdentifier(opts?: object): this is NodePath; - isJSXMemberExpression(opts?: object): this is NodePath; - isJSXNamespacedName(opts?: object): this is NodePath; - isJSXOpeningElement(opts?: object): this is NodePath; - isJSXSpreadAttribute(opts?: object): this is NodePath; - isJSXText(opts?: object): this is NodePath; - isNoop(opts?: object): this is NodePath; - isParenthesizedExpression(opts?: object): this is NodePath; - isAwaitExpression(opts?: object): this is NodePath; - isBindExpression(opts?: object): this is NodePath; - isDecorator(opts?: object): this is NodePath; - isDoExpression(opts?: object): this is NodePath; - isExportDefaultSpecifier(opts?: object): this is NodePath; - isExportNamespaceSpecifier(opts?: object): this is NodePath; - isRestProperty(opts?: object): this is NodePath; - isSpreadProperty(opts?: object): this is NodePath; - isExpression(opts?: object): this is NodePath; - isBinary(opts?: object): this is NodePath; - isScopable(opts?: object): this is NodePath; - isBlockParent(opts?: object): this is NodePath; - isBlock(opts?: object): this is NodePath; - isStatement(opts?: object): this is NodePath; - isTerminatorless(opts?: object): this is NodePath; - isCompletionStatement(opts?: object): this is NodePath; - isConditional(opts?: object): this is NodePath; - isLoop(opts?: object): this is NodePath; - isWhile(opts?: object): this is NodePath; - isExpressionWrapper(opts?: object): this is NodePath; - isFor(opts?: object): this is NodePath; - isForXStatement(opts?: object): this is NodePath; - isFunction(opts?: object): this is NodePath; - isFunctionParent(opts?: object): this is NodePath; - isPureish(opts?: object): this is NodePath; - isDeclaration(opts?: object): this is NodePath; - isLVal(opts?: object): this is NodePath; - isLiteral(opts?: object): this is NodePath; - isImmutable(opts?: object): this is NodePath; - isUserWhitespacable(opts?: object): this is NodePath; - isMethod(opts?: object): this is NodePath; - isObjectMember(opts?: object): this is NodePath; - isProperty(opts?: object): this is NodePath; - isUnaryLike(opts?: object): this is NodePath; - isPattern(opts?: object): this is NodePath; - isClass(opts?: object): this is NodePath; - isModuleDeclaration(opts?: object): this is NodePath; - isExportDeclaration(opts?: object): this is NodePath; - isModuleSpecifier(opts?: object): this is NodePath; - isFlow(opts?: object): this is NodePath; - isFlowBaseAnnotation(opts?: object): this is NodePath; - isFlowDeclaration(opts?: object): this is NodePath; - isJSX(opts?: object): this is NodePath; - isNumberLiteral(opts?: object): this is NodePath; - isRegexLiteral(opts?: object): this is NodePath; - isReferencedIdentifier(opts?: object): this is NodePath; - isReferencedMemberExpression(opts?: object): this is NodePath; - isBindingIdentifier(opts?: object): this is NodePath; - isScope(opts?: object): this is NodePath; - isReferenced(opts?: object): boolean; - isBlockScoped(opts?: object): this is NodePath; - isVar(opts?: object): this is NodePath; - isUser(opts?: object): boolean; - isGenerated(opts?: object): boolean; - isPure(opts?: object): boolean; - - // ------------------------- assertXXX ------------------------- - assertArrayExpression(opts?: object): void; - assertAssignmentExpression(opts?: object): void; - assertBinaryExpression(opts?: object): void; - assertDirective(opts?: object): void; - assertDirectiveLiteral(opts?: object): void; - assertBlockStatement(opts?: object): void; - assertBreakStatement(opts?: object): void; - assertCallExpression(opts?: object): void; - assertCatchClause(opts?: object): void; - assertConditionalExpression(opts?: object): void; - assertContinueStatement(opts?: object): void; - assertDebuggerStatement(opts?: object): void; - assertDoWhileStatement(opts?: object): void; - assertEmptyStatement(opts?: object): void; - assertExpressionStatement(opts?: object): void; - assertFile(opts?: object): void; - assertForInStatement(opts?: object): void; - assertForStatement(opts?: object): void; - assertFunctionDeclaration(opts?: object): void; - assertFunctionExpression(opts?: object): void; - assertIdentifier(opts?: object): void; - assertIfStatement(opts?: object): void; - assertLabeledStatement(opts?: object): void; - assertStringLiteral(opts?: object): void; - assertNumericLiteral(opts?: object): void; - assertNullLiteral(opts?: object): void; - assertBooleanLiteral(opts?: object): void; - assertRegExpLiteral(opts?: object): void; - assertLogicalExpression(opts?: object): void; - assertMemberExpression(opts?: object): void; - assertNewExpression(opts?: object): void; - assertProgram(opts?: object): void; - assertObjectExpression(opts?: object): void; - assertObjectMethod(opts?: object): void; - assertObjectProperty(opts?: object): void; - assertRestElement(opts?: object): void; - assertReturnStatement(opts?: object): void; - assertSequenceExpression(opts?: object): void; - assertSwitchCase(opts?: object): void; - assertSwitchStatement(opts?: object): void; - assertThisExpression(opts?: object): void; - assertThrowStatement(opts?: object): void; - assertTryStatement(opts?: object): void; - assertUnaryExpression(opts?: object): void; - assertUpdateExpression(opts?: object): void; - assertVariableDeclaration(opts?: object): void; - assertVariableDeclarator(opts?: object): void; - assertWhileStatement(opts?: object): void; - assertWithStatement(opts?: object): void; - assertAssignmentPattern(opts?: object): void; - assertArrayPattern(opts?: object): void; - assertArrowFunctionExpression(opts?: object): void; - assertClassBody(opts?: object): void; - assertClassDeclaration(opts?: object): void; - assertClassExpression(opts?: object): void; - assertExportAllDeclaration(opts?: object): void; - assertExportDefaultDeclaration(opts?: object): void; - assertExportNamedDeclaration(opts?: object): void; - assertExportSpecifier(opts?: object): void; - assertForOfStatement(opts?: object): void; - assertImportDeclaration(opts?: object): void; - assertImportDefaultSpecifier(opts?: object): void; - assertImportNamespaceSpecifier(opts?: object): void; - assertImportSpecifier(opts?: object): void; - assertMetaProperty(opts?: object): void; - assertClassMethod(opts?: object): void; - assertObjectPattern(opts?: object): void; - assertSpreadElement(opts?: object): void; - assertSuper(opts?: object): void; - assertTaggedTemplateExpression(opts?: object): void; - assertTemplateElement(opts?: object): void; - assertTemplateLiteral(opts?: object): void; - assertYieldExpression(opts?: object): void; - assertAnyTypeAnnotation(opts?: object): void; - assertArrayTypeAnnotation(opts?: object): void; - assertBooleanTypeAnnotation(opts?: object): void; - assertBooleanLiteralTypeAnnotation(opts?: object): void; - assertNullLiteralTypeAnnotation(opts?: object): void; - assertClassImplements(opts?: object): void; - assertClassProperty(opts?: object): void; - assertDeclareClass(opts?: object): void; - assertDeclareFunction(opts?: object): void; - assertDeclareInterface(opts?: object): void; - assertDeclareModule(opts?: object): void; - assertDeclareTypeAlias(opts?: object): void; - assertDeclareVariable(opts?: object): void; - assertExistentialTypeParam(opts?: object): void; - assertFunctionTypeAnnotation(opts?: object): void; - assertFunctionTypeParam(opts?: object): void; - assertGenericTypeAnnotation(opts?: object): void; - assertInterfaceExtends(opts?: object): void; - assertInterfaceDeclaration(opts?: object): void; - assertIntersectionTypeAnnotation(opts?: object): void; - assertMixedTypeAnnotation(opts?: object): void; - assertNullableTypeAnnotation(opts?: object): void; - assertNumericLiteralTypeAnnotation(opts?: object): void; - assertNumberTypeAnnotation(opts?: object): void; - assertStringLiteralTypeAnnotation(opts?: object): void; - assertStringTypeAnnotation(opts?: object): void; - assertThisTypeAnnotation(opts?: object): void; - assertTupleTypeAnnotation(opts?: object): void; - assertTypeofTypeAnnotation(opts?: object): void; - assertTypeAlias(opts?: object): void; - assertTypeAnnotation(opts?: object): void; - assertTypeCastExpression(opts?: object): void; - assertTypeParameterDeclaration(opts?: object): void; - assertTypeParameterInstantiation(opts?: object): void; - assertObjectTypeAnnotation(opts?: object): void; - assertObjectTypeCallProperty(opts?: object): void; - assertObjectTypeIndexer(opts?: object): void; - assertObjectTypeProperty(opts?: object): void; - assertQualifiedTypeIdentifier(opts?: object): void; - assertUnionTypeAnnotation(opts?: object): void; - assertVoidTypeAnnotation(opts?: object): void; - assertJSXAttribute(opts?: object): void; - assertJSXClosingElement(opts?: object): void; - assertJSXElement(opts?: object): void; - assertJSXEmptyExpression(opts?: object): void; - assertJSXExpressionContainer(opts?: object): void; - assertJSXIdentifier(opts?: object): void; - assertJSXMemberExpression(opts?: object): void; - assertJSXNamespacedName(opts?: object): void; - assertJSXOpeningElement(opts?: object): void; - assertJSXSpreadAttribute(opts?: object): void; - assertJSXText(opts?: object): void; - assertNoop(opts?: object): void; - assertParenthesizedExpression(opts?: object): void; - assertAwaitExpression(opts?: object): void; - assertBindExpression(opts?: object): void; - assertDecorator(opts?: object): void; - assertDoExpression(opts?: object): void; - assertExportDefaultSpecifier(opts?: object): void; - assertExportNamespaceSpecifier(opts?: object): void; - assertRestProperty(opts?: object): void; - assertSpreadProperty(opts?: object): void; - assertExpression(opts?: object): void; - assertBinary(opts?: object): void; - assertScopable(opts?: object): void; - assertBlockParent(opts?: object): void; - assertBlock(opts?: object): void; - assertStatement(opts?: object): void; - assertTerminatorless(opts?: object): void; - assertCompletionStatement(opts?: object): void; - assertConditional(opts?: object): void; - assertLoop(opts?: object): void; - assertWhile(opts?: object): void; - assertExpressionWrapper(opts?: object): void; - assertFor(opts?: object): void; - assertForXStatement(opts?: object): void; - assertFunction(opts?: object): void; - assertFunctionParent(opts?: object): void; - assertPureish(opts?: object): void; - assertDeclaration(opts?: object): void; - assertLVal(opts?: object): void; - assertLiteral(opts?: object): void; - assertImmutable(opts?: object): void; - assertUserWhitespacable(opts?: object): void; - assertMethod(opts?: object): void; - assertObjectMember(opts?: object): void; - assertProperty(opts?: object): void; - assertUnaryLike(opts?: object): void; - assertPattern(opts?: object): void; - assertClass(opts?: object): void; - assertModuleDeclaration(opts?: object): void; - assertExportDeclaration(opts?: object): void; - assertModuleSpecifier(opts?: object): void; - assertFlow(opts?: object): void; - assertFlowBaseAnnotation(opts?: object): void; - assertFlowDeclaration(opts?: object): void; - assertJSX(opts?: object): void; - assertNumberLiteral(opts?: object): void; - assertRegexLiteral(opts?: object): 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: any, msg: string, Error: ErrorConstructor): Error; + buildError(node: Node, msg: string, Error: new (message?: string) => E): E; } export class Hub implements HubInterface { - constructor(file: any, options: any); - file: any; - options: any; + constructor(); getCode(): string | undefined; getScope(): Scope | undefined; addHelper(name: string): any; - buildError(node: any, msg: string, Constructor: typeof Error): Error; + buildError(node: Node, msg: string, Constructor: new (message?: string) => E): E; } export interface TraversalContext { diff --git a/types/babel__traverse/tslint.json b/types/babel__traverse/tslint.json index a81218c6687bec..3db14f85eaf7b9 100644 --- a/types/babel__traverse/tslint.json +++ b/types/babel__traverse/tslint.json @@ -1,6 +1 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "no-unnecessary-type-assertion": false - } -} +{ "extends": "dtslint/dt.json" }