UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

1,211 lines (1,210 loc) 174 kB
import * as ts from "typescript"; import CodeBlockWriter from "code-block-writer"; import { Disposable } from "./../../utils"; import { SourceFile } from "./../file"; import { Symbol } from "./Symbol"; import * as compiler from "./../../compiler"; export declare class Node<NodeType extends ts.Node = ts.Node> implements Disposable { /** * Gets the underlying compiler node. */ readonly compilerNode: NodeType; /** * Gets the syntax kind. */ getKind(): ts.SyntaxKind; /** * Gets the syntax kind name. */ getKindName(): string; /** * Gets the compiler symbol. */ 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 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<ts.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<ts.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<ts.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<ts.Node> | undefined; /** * Gets the previous siblings. * * Note: Closest sibling is the zero index. */ getPreviousSiblings(): Node<ts.Node>[]; /** * Gets the next siblings. * * Note: Closest sibling is the zero index. */ getNextSiblings(): Node<ts.Node>[]; /** * Gets the children of the node. */ getChildren(): Node[]; /** * Gets the child syntax list or throws if it doesn't exist. */ getChildSyntaxListOrThrow(): Node<ts.Node>; /** * Gets the child syntax list if it exists. */ getChildSyntaxList(): Node | 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 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 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<ts.Node> | undefined; /** * Gets the parent or throws an error if it doesn't exist. */ getParentOrThrow(): Node<ts.Node>; /** * Gets the last token of this node. Usually this is a close brace. */ getLastToken(): Node<ts.Node>; /** * Gets if this node is in a syntax list. */ isInSyntaxList(): boolean; /** * Gets the parent if it's a syntax list or throws an error otherwise. */ getParentSyntaxListOrThrow(): Node<ts.Node>; /** * Gets the parent if it's a syntax list. */ getParentSyntaxList(): Node<ts.Node> | undefined; /** * Gets the child index of this node relative to the parent. */ getChildIndex(): number; /** * Gets the indentation text. */ getIndentationText(): string; /** * Gets the next indentation level text. */ getChildIndentationText(): string; /** * Gets the position of the start of the line that this node is on. */ getStartLinePos(): number; /** * Gets if this is the first node on the current line. */ isFirstNodeOnLine(): boolean; /** * Replaces the text of the current node with new text. * * This will dispose the current node and return a new node that can be asserted or type guarded to the correct type. * @param writerFunction - Writer function to replace the text with. * @returns The new node. */ replaceWithText(writerFunction: (writer: CodeBlockWriter) => void): Node; /** * Replaces the text of the current node with new text. * * This will dispose the current node and return a new node that can be asserted or type guarded to the correct type. * @param text - Text to replace with. * @returns The new node. */ replaceWithText(text: string): Node; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ConstructSignature): compiler.ConstructSignatureDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.Decorator): compiler.Decorator[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.EnumDeclaration): compiler.EnumDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.EnumMember): compiler.EnumMember[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ExportDeclaration): compiler.ExportDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ExportSpecifier): compiler.ExportSpecifier[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ExpressionWithTypeArguments): compiler.ExpressionWithTypeArguments[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.FunctionDeclaration): compiler.FunctionDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.GetAccessor): compiler.GetAccessorDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.HeritageClause): compiler.HeritageClause[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.Identifier): compiler.Identifier[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ImportDeclaration): compiler.ImportDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ImportSpecifier): compiler.ImportSpecifier[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.InterfaceDeclaration): compiler.InterfaceDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.MethodDeclaration): compiler.MethodDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.MethodSignature): compiler.MethodSignature[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.ModuleDeclaration): compiler.NamespaceDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.NumericLiteral): compiler.Expression[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.Parameter): compiler.ParameterDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.PropertyAccessExpression): compiler.PropertyAccessExpression[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.PropertyDeclaration): compiler.PropertyDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.PropertySignature): compiler.PropertySignature[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.QualifiedName): compiler.QualifiedName[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.FirstNode): compiler.QualifiedName[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.SetAccessor): compiler.SetAccessorDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.TypeAliasDeclaration): compiler.TypeAliasDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.TypeParameter): compiler.TypeParameterDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.TypeReference): compiler.TypeReferenceNode[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.VariableDeclaration): compiler.VariableDeclaration[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.VariableDeclarationList): compiler.VariableDeclarationList[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.VariableStatement): compiler.VariableStatement[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind.JSDocComment): compiler.JSDoc[]; /** * Gets the children based on a kind. * @param kind - Syntax kind. */ getChildrenOfKind(kind: ts.SyntaxKind): Node<ts.Node>[]; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ConstructSignature): compiler.ConstructSignatureDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.Decorator): compiler.Decorator; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.EnumDeclaration): compiler.EnumDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.EnumMember): compiler.EnumMember; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ExportDeclaration): compiler.ExportDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ExportSpecifier): compiler.ExportSpecifier; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ExpressionWithTypeArguments): compiler.ExpressionWithTypeArguments; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.FunctionDeclaration): compiler.FunctionDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.GetAccessor): compiler.GetAccessorDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.HeritageClause): compiler.HeritageClause; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.Identifier): compiler.Identifier; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ImportDeclaration): compiler.ImportDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ImportSpecifier): compiler.ImportSpecifier; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.InterfaceDeclaration): compiler.InterfaceDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.MethodDeclaration): compiler.MethodDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.MethodSignature): compiler.MethodSignature; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.ModuleDeclaration): compiler.NamespaceDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.NumericLiteral): compiler.Expression; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.Parameter): compiler.ParameterDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.PropertyAccessExpression): compiler.PropertyAccessExpression; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.PropertyDeclaration): compiler.PropertyDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.PropertySignature): compiler.PropertySignature; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.QualifiedName): compiler.QualifiedName; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.FirstNode): compiler.QualifiedName; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.SetAccessor): compiler.SetAccessorDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.TypeAliasDeclaration): compiler.TypeAliasDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.TypeParameter): compiler.TypeParameterDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.TypeReference): compiler.TypeReferenceNode; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.VariableDeclaration): compiler.VariableDeclaration; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.VariableDeclarationList): compiler.VariableDeclarationList; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.VariableStatement): compiler.VariableStatement; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind.JSDocComment): compiler.JSDoc; /** * Gets the first child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildByKindOrThrow(kind: ts.SyntaxKind): Node<ts.Node>; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ConstructSignature): compiler.ConstructSignatureDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.Decorator): compiler.Decorator | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.EnumDeclaration): compiler.EnumDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.EnumMember): compiler.EnumMember | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ExportDeclaration): compiler.ExportDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ExportSpecifier): compiler.ExportSpecifier | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ExpressionWithTypeArguments): compiler.ExpressionWithTypeArguments | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.FunctionDeclaration): compiler.FunctionDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.GetAccessor): compiler.GetAccessorDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.HeritageClause): compiler.HeritageClause | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.Identifier): compiler.Identifier | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ImportDeclaration): compiler.ImportDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ImportSpecifier): compiler.ImportSpecifier | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.InterfaceDeclaration): compiler.InterfaceDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.MethodDeclaration): compiler.MethodDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.MethodSignature): compiler.MethodSignature | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.ModuleDeclaration): compiler.NamespaceDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.NumericLiteral): compiler.Expression | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.Parameter): compiler.ParameterDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.PropertyAccessExpression): compiler.PropertyAccessExpression | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.PropertyDeclaration): compiler.PropertyDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.PropertySignature): compiler.PropertySignature | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.QualifiedName): compiler.QualifiedName | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.FirstNode): compiler.QualifiedName | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.SetAccessor): compiler.SetAccessorDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.TypeAliasDeclaration): compiler.TypeAliasDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.TypeParameter): compiler.TypeParameterDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.TypeReference): compiler.TypeReferenceNode | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.VariableDeclaration): compiler.VariableDeclaration | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.VariableDeclarationList): compiler.VariableDeclarationList | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.VariableStatement): compiler.VariableStatement | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind.JSDocComment): compiler.JSDoc | undefined; /** * Gets the first child by syntax kind. * @param kind - Syntax kind. */ getFirstChildByKind(kind: ts.SyntaxKind): Node<ts.Node> | undefined; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ConstructSignature): compiler.ConstructSignatureDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.Decorator): compiler.Decorator; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.EnumDeclaration): compiler.EnumDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.EnumMember): compiler.EnumMember; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ExportDeclaration): compiler.ExportDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ExportSpecifier): compiler.ExportSpecifier; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ExpressionWithTypeArguments): compiler.ExpressionWithTypeArguments; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.FunctionDeclaration): compiler.FunctionDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.GetAccessor): compiler.GetAccessorDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.HeritageClause): compiler.HeritageClause; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.Identifier): compiler.Identifier; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ImportDeclaration): compiler.ImportDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ImportSpecifier): compiler.ImportSpecifier; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.InterfaceDeclaration): compiler.InterfaceDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.MethodDeclaration): compiler.MethodDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.MethodSignature): compiler.MethodSignature; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.ModuleDeclaration): compiler.NamespaceDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.NumericLiteral): compiler.Expression; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.Parameter): compiler.ParameterDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.PropertyAccessExpression): compiler.PropertyAccessExpression; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.PropertyDeclaration): compiler.PropertyDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.PropertySignature): compiler.PropertySignature; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.QualifiedName): compiler.QualifiedName; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.FirstNode): compiler.QualifiedName; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.SetAccessor): compiler.SetAccessorDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.TypeAliasDeclaration): compiler.TypeAliasDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.TypeParameter): compiler.TypeParameterDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.TypeReference): compiler.TypeReferenceNode; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.VariableDeclaration): compiler.VariableDeclaration; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.VariableDeclarationList): compiler.VariableDeclarationList; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.VariableStatement): compiler.VariableStatement; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind.JSDocComment): compiler.JSDoc; /** * Gets the first child if it matches the specified syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getFirstChildIfKindOrThrow(kind: ts.SyntaxKind): Node<ts.Node>; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ConstructSignature): compiler.ConstructSignatureDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.Decorator): compiler.Decorator | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.EnumDeclaration): compiler.EnumDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.EnumMember): compiler.EnumMember | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ExportDeclaration): compiler.ExportDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ExportSpecifier): compiler.ExportSpecifier | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ExpressionWithTypeArguments): compiler.ExpressionWithTypeArguments | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.FunctionDeclaration): compiler.FunctionDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.GetAccessor): compiler.GetAccessorDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.HeritageClause): compiler.HeritageClause | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.Identifier): compiler.Identifier | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ImportDeclaration): compiler.ImportDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ImportSpecifier): compiler.ImportSpecifier | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.InterfaceDeclaration): compiler.InterfaceDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.MethodDeclaration): compiler.MethodDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.MethodSignature): compiler.MethodSignature | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.ModuleDeclaration): compiler.NamespaceDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.NumericLiteral): compiler.Expression | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.Parameter): compiler.ParameterDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.PropertyAccessExpression): compiler.PropertyAccessExpression | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.PropertyDeclaration): compiler.PropertyDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.PropertySignature): compiler.PropertySignature | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.QualifiedName): compiler.QualifiedName | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.FirstNode): compiler.QualifiedName | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.SetAccessor): compiler.SetAccessorDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.TypeAliasDeclaration): compiler.TypeAliasDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.TypeParameter): compiler.TypeParameterDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.TypeReference): compiler.TypeReferenceNode | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.VariableDeclaration): compiler.VariableDeclaration | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.VariableDeclarationList): compiler.VariableDeclarationList | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.VariableStatement): compiler.VariableStatement | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind.JSDocComment): compiler.JSDoc | undefined; /** * Gets the first child if it matches the specified syntax kind. * @param kind - Syntax kind. */ getFirstChildIfKind(kind: ts.SyntaxKind): Node<ts.Node> | undefined; /** * Gets the last child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getLastChildByKindOrThrow(kind: ts.SyntaxKind.SourceFile): compiler.SourceFile; /** * Gets the last child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getLastChildByKindOrThrow(kind: ts.SyntaxKind.ArrayLiteralExpression): compiler.ArrayLiteralExpression; /** * Gets the last child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getLastChildByKindOrThrow(kind: ts.SyntaxKind.CallExpression): compiler.CallExpression; /** * Gets the last child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getLastChildByKindOrThrow(kind: ts.SyntaxKind.ClassDeclaration): compiler.ClassDeclaration; /** * Gets the last child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ getLastChildByKindOrThrow(kind: ts.SyntaxKind.Constructor): compiler.ConstructorDeclaration; /** * Gets the last child by syntax kind or throws an error if not found. * @param kind - Syntax kind. */ g