UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

979 lines (978 loc) 432 kB
import * as ts from "typescript"; import CodeBlockWriter from "code-block-writer"; import { SourceFile } from "./../file"; import { Symbol } from "./Symbol"; import { SyntaxList } from "./SyntaxList"; import * as compiler from "./../../compiler"; export declare class Node<NodeType extends ts.Node = ts.Node> { /** * Gets the underlying compiler node. */ readonly compilerNode: NodeType; /** * Releases the node and all its descendants from the underlying node cache and ast. * * This is useful if you want to improve the performance of manipulation by not tracking this node anymore. */ forget(): void; /** * Gets the syntax kind. */ getKind(): ts.SyntaxKind; /** * Gets the syntax kind name. */ getKindName(): string; /** * Gets the symbol or throws an error if it doesn't exist. */ getSymbolOrThrow(): Symbol; /** * Gets the compiler symbol or undefined if it doesn't exist. */ getSymbol(): Symbol | undefined; /** * If the node contains the provided range (inclusive). * @param pos - Start position. * @param end - End position. */ containsRange(pos: number, end: number): boolean; /** * Gets if the specified position is within a string. * @param pos - Position. */ isInStringAtPos(pos: number): boolean; /** * Gets the first child by a condition or throws. * @param condition - Condition. */ getFirstChildOrThrow(condition?: (node: Node) => boolean): Node<ts.Node>; /** * Gets the first child by a condition. * @param condition - Condition. */ getFirstChild(condition?: (node: Node) => boolean): Node | undefined; /** * Gets the last child by a condition or throws. * @param condition - Condition. */ getLastChildOrThrow(condition?: (node: Node) => boolean): Node<ts.Node>; /** * Gets the last child by a condition. * @param condition - Condition. */ getLastChild(condition?: (node: Node) => boolean): Node | undefined; /** * Gets the first descendant by a condition or throws. * @param condition - Condition. */ getFirstDescendantOrThrow(condition?: (node: Node) => boolean): Node<ts.Node>; /** * Gets the first descendant by a condition. * @param condition - Condition. */ getFirstDescendant(condition?: (node: Node) => boolean): Node<ts.Node> | undefined; /** * Gets the previous sibling or throws. * @param condition - Optional condition for getting the previous sibling. */ getPreviousSiblingOrThrow(condition?: (node: Node) => boolean): Node<ts.Node>; /** * Gets the previous sibling. * @param condition - Optional condition for getting the previous sibling. */ getPreviousSibling(condition?: (node: Node) => boolean): Node | undefined; /** * Gets the next sibling or throws. * @param condition - Optional condition for getting the next sibling. */ getNextSiblingOrThrow(condition?: (node: Node) => boolean): Node<ts.Node>; /** * Gets the next sibling. * @param condition - Optional condition for getting the previous sibling. */ getNextSibling(condition?: (node: Node) => boolean): Node | undefined; /** * Gets the previous siblings. * * Note: Closest sibling is the zero index. */ getPreviousSiblings(): Node[]; /** * Gets the next siblings. * * Note: Closest sibling is the zero index. */ getNextSiblings(): Node[]; /** * Gets the children of the node. */ getChildren(): Node[]; /** * Gets the child at the specified index. * @param index - Index of the child. */ getChildAtIndex(index: number): Node; /** * Gets the child syntax list or throws if it doesn't exist. */ getChildSyntaxListOrThrow(): SyntaxList; /** * Gets the child syntax list if it exists. */ getChildSyntaxList(): SyntaxList | undefined; /** * Gets the node's descendants. */ getDescendants(): Node[]; /** * Gets the child count. */ getChildCount(): number; /** * Gets the child at the provided position, or undefined if not found. * @param pos - Position to search for. */ getChildAtPos(pos: number): Node | undefined; /** * Gets the most specific descendant at the provided position, or undefined if not found. * @param pos - Position to search for. */ getDescendantAtPos(pos: number): Node | undefined; /** * Gets the most specific descendant at the provided start position with the specified width, or undefined if not found. * @param start - Start position to search for. * @param width - Width of the node to search for. */ getDescendantAtStartWithWidth(start: number, width: number): Node | undefined; /** * Gets the start position with leading trivia. */ getPos(): number; /** * Gets the end position. */ getEnd(): number; /** * Gets the start position without leading trivia. */ getStart(): number; /** * Gets the first position from the pos that is not whitespace. */ getNonWhitespaceStart(): number; /** * Gets the width of the node (length without trivia). */ getWidth(): number; /** * Gets the full width of the node (length with trivia). */ getFullWidth(): number; /** * Gets the text without leading trivia. */ getText(): string; /** * Gets the full text with leading trivia. */ getFullText(): string; /** * Gets the combined modifier flags. */ getCombinedModifierFlags(): ts.ModifierFlags; /** * Gets the source file. */ getSourceFile(): SourceFile; /** * Gets a compiler node property wrapped in a Node. * @param propertyName - Property name. */ getNodeProperty<KeyType extends keyof NodeType>(propertyName: KeyType): Node<NodeType[KeyType]>; /** * Goes up the tree getting all the parents in ascending order. */ getAncestors(): Node<ts.Node>[]; /** * Get the node's parent. */ getParent(): Node | undefined; /** * Gets the parent or throws an error if it doesn't exist. */ getParentOrThrow(): Node<ts.Node>; /** * Goes up the parents (ancestors) of the node while a condition is true. * Throws if the initial parent doesn't match the condition. * @param condition - Condition that tests the parent to see if the expression is true. */ getParentWhileOrThrow(condition: (node: Node) => boolean): Node<ts.Node>; /** * Goes up the parents (ancestors) of the node while a condition is true. * Returns undefined if the initial parent doesn't match the condition. * @param condition - Condition that tests the parent to see if the expression is true. */ getParentWhile(condition: (node: Node) => boolean): Node<ts.Node> | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.BinaryExpression): compiler.BinaryExpression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.Block): compiler.Block; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ConstructSignature): compiler.ConstructSignatureDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ComputedPropertyName): compiler.ComputedPropertyName; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.Decorator): compiler.Decorator; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.EnumDeclaration): compiler.EnumDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.EnumMember): compiler.EnumMember; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ExportAssignment): compiler.ExportAssignment; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ExportDeclaration): compiler.ExportDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ExportSpecifier): compiler.ExportSpecifier; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ExpressionWithTypeArguments): compiler.ExpressionWithTypeArguments; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ExpressionStatement): compiler.ExpressionStatement; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.FunctionDeclaration): compiler.FunctionDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.FunctionExpression): compiler.FunctionExpression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.GetAccessor): compiler.GetAccessorDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.HeritageClause): compiler.HeritageClause; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.Identifier): compiler.Identifier; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ImportDeclaration): compiler.ImportDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ImportSpecifier): compiler.ImportSpecifier; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.InterfaceDeclaration): compiler.InterfaceDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.MethodDeclaration): compiler.MethodDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.MethodSignature): compiler.MethodSignature; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ModuleDeclaration): compiler.NamespaceDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.NumericLiteral): compiler.NumericLiteral; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.FirstLiteralToken): compiler.NumericLiteral; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ObjectLiteralExpression): compiler.ObjectLiteralExpression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.Parameter): compiler.ParameterDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.PropertyAccessExpression): compiler.PropertyAccessExpression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.PropertyAssignment): compiler.PropertyAssignment; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.PropertyDeclaration): compiler.PropertyDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.PropertySignature): compiler.PropertySignature; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.QualifiedName): compiler.QualifiedName; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.FirstNode): compiler.QualifiedName; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.RegularExpressionLiteral): compiler.RegularExpressionLiteral; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ReturnStatement): compiler.ReturnStatement; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.SetAccessor): compiler.SetAccessorDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ShorthandPropertyAssignment): compiler.ShorthandPropertyAssignment; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.SpreadAssignment): compiler.SpreadAssignment; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.StringLiteral): compiler.StringLiteral; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.SyntaxList): compiler.SyntaxList; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.TypeAliasDeclaration): compiler.TypeAliasDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.TypeParameter): compiler.TypeParameterDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.TypeReference): compiler.TypeReferenceNode; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.VariableDeclaration): compiler.VariableDeclaration; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.VariableStatement): compiler.VariableStatement; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocComment): compiler.JSDoc; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.FirstTypeNode): compiler.TypeNode; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.LastTypeNode): compiler.TypeNode; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocTag): compiler.JSDocUnknownTag; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocAugmentsTag): compiler.JSDocAugmentsTag; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocClassTag): compiler.JSDocClassTag; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocReturnTag): compiler.JSDocReturnTag; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocTypeTag): compiler.JSDocTypeTag; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocTypedefTag): compiler.JSDocTypedefTag; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.JSDocPropertyTag): compiler.JSDocPropertyTag; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.AnyKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.BooleanKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ImportKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.NeverKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.NullKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.NumberKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ObjectKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.StringKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.SymbolKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.SuperKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.ThisKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.UndefinedKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.VoidKeyword): compiler.Expression; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.FalseKeyword): compiler.BooleanLiteral; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind.TrueKeyword): compiler.BooleanLiteral; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Throws if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKindOrThrow(kind: ts.SyntaxKind): Node<ts.Node>; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.BinaryExpression): compiler.BinaryExpression | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.Block): compiler.Block | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ConstructSignature): compiler.ConstructSignatureDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ComputedPropertyName): compiler.ComputedPropertyName | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.Decorator): compiler.Decorator | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.EnumDeclaration): compiler.EnumDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.EnumMember): compiler.EnumMember | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ExportAssignment): compiler.ExportAssignment | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ExportDeclaration): compiler.ExportDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ExportSpecifier): compiler.ExportSpecifier | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ExpressionWithTypeArguments): compiler.ExpressionWithTypeArguments | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ExpressionStatement): compiler.ExpressionStatement | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.FunctionDeclaration): compiler.FunctionDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.FunctionExpression): compiler.FunctionExpression | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.GetAccessor): compiler.GetAccessorDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.HeritageClause): compiler.HeritageClause | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.Identifier): compiler.Identifier | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ImportDeclaration): compiler.ImportDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ImportSpecifier): compiler.ImportSpecifier | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.InterfaceDeclaration): compiler.InterfaceDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.MethodDeclaration): compiler.MethodDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.MethodSignature): compiler.MethodSignature | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ModuleDeclaration): compiler.NamespaceDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.NumericLiteral): compiler.NumericLiteral | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.FirstLiteralToken): compiler.NumericLiteral | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ObjectLiteralExpression): compiler.ObjectLiteralExpression | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.Parameter): compiler.ParameterDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.PropertyAccessExpression): compiler.PropertyAccessExpression | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.PropertyAssignment): compiler.PropertyAssignment | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.PropertyDeclaration): compiler.PropertyDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.PropertySignature): compiler.PropertySignature | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.QualifiedName): compiler.QualifiedName | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.FirstNode): compiler.QualifiedName | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.RegularExpressionLiteral): compiler.RegularExpressionLiteral | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ReturnStatement): compiler.ReturnStatement | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.SetAccessor): compiler.SetAccessorDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.ShorthandPropertyAssignment): compiler.ShorthandPropertyAssignment | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.SpreadAssignment): compiler.SpreadAssignment | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.StringLiteral): compiler.StringLiteral | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.SyntaxList): compiler.SyntaxList | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.TypeAliasDeclaration): compiler.TypeAliasDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.TypeParameter): compiler.TypeParameterDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.TypeReference): compiler.TypeReferenceNode | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.VariableDeclaration): compiler.VariableDeclaration | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(kind: ts.SyntaxKind.VariableStatement): compiler.VariableStatement | undefined; /** * Goes up the parents (ancestors) of the node while the parent is the specified syntax kind. * Returns undefined if the initial parent is not the specified syntax kind. * @param kind - Syntax kind to check for. */ getParentWhileKind(k