ts-codemod-lib
    Preparing search index...
    • Parameters

      • node: {
            compilerNode: {
                end: number;
                flags: NodeFlags;
                kind: SyntaxKind;
                parent: { readonly kind: SyntaxKind; readonly flags: NodeFlags; readonly parent: ...; readonly getSourceFile: () => SourceFile; readonly getChildCount: (sourceFile?: SourceFile | undefined) => number; ... 14 more ...; readonly end: number; };
                pos: number;
                forEachChild<T>(
                    cbNode: (node: Node) => T | undefined,
                    cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined,
                ): T | undefined;
                getChildAt(index: number, sourceFile?: SourceFile): Node;
                getChildCount(sourceFile?: SourceFile): number;
                getChildren(sourceFile?: SourceFile): readonly Node[];
                getEnd(): number;
                getFirstToken(sourceFile?: SourceFile): Node | undefined;
                getFullStart(): number;
                getFullText(sourceFile?: SourceFile): string;
                getFullWidth(): number;
                getLastToken(sourceFile?: SourceFile): Node | undefined;
                getLeadingTriviaWidth(sourceFile?: SourceFile): number;
                getSourceFile(): SourceFile;
                getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
                getText(sourceFile?: SourceFile): string;
                getWidth(sourceFile?: SourceFileLike): number;
            };
            appendWhitespace(textOrWriterFunction: string | WriterFunction): void;
            asKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            asKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            containsRange(pos: number, end: number): boolean;
            forEachChild<T>(
                cbNode: (node: Node) => T | undefined,
                cbNodeArray?: (nodes: Node<Node>[]) => T | undefined,
            ): T | undefined;
            forEachChildAsArray(): Node<Node>[];
            forEachDescendant<T>(
                cbNode: (
                    node: Node,
                    traversal: ForEachDescendantTraversalControl,
                ) => T | undefined,
                cbNodeArray?: (
                    nodes: Node<Node>[],
                    traversal: ForEachDescendantTraversalControl,
                ) => T | undefined,
            ): T | undefined;
            forEachDescendantAsArray(): Node<Node>[];
            forget(): void;
            forgetDescendants(): void;
            formatText(settings?: FormatCodeSettings): void;
            getAncestors(): Node<Node>[];
            getChildAtIndex(index: number): Node;
            getChildAtIndexIfKind<TKind extends SyntaxKind>(
                index: number,
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getChildAtIndexIfKindOrThrow<TKind extends SyntaxKind>(
                index: number,
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getChildAtPos(pos: number): Node<Node> | undefined;
            getChildCount(): number;
            getChildIndentationLevel(): number;
            getChildIndentationText(offset?: number): string;
            getChildIndex(): number;
            getChildren(): Node<Node>[];
            getChildrenOfKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind][];
            getChildSyntaxList(): SyntaxList | undefined;
            getChildSyntaxListOrThrow(message?: string | (() => string)): SyntaxList;
            getCombinedModifierFlags(): ModifierFlags;
            getDescendantAtPos(pos: number): Node<Node> | undefined;
            getDescendantAtStartWithWidth(
                start: number,
                width: number,
            ): Node<Node> | undefined;
            getDescendants(): Node<Node>[];
            getDescendantsOfKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind][];
            getDescendantStatements(): (Expression<Expression> | Statement<Statement>)[];
            getEnd(): number;
            getEndLineNumber(): number;
            getFirstAncestor<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
            ): T | undefined;
            getFirstAncestor(
                condition?: (node: Node) => boolean,
            ): Node<Node> | undefined;
            getFirstAncestorByKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getFirstAncestorByKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getFirstAncestorOrThrow<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
            ): T;
            getFirstAncestorOrThrow(condition?: (node: Node) => boolean): Node;
            getFirstChild<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
            ): T | undefined;
            getFirstChild(condition?: (node: Node) => boolean): Node<Node> | undefined;
            getFirstChildByKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getFirstChildByKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getFirstChildIfKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getFirstChildIfKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getFirstChildOrThrow<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
                message?: string | (() => string),
            ): T;
            getFirstChildOrThrow(
                condition?: (node: Node) => boolean,
                message?: string | (() => string),
            ): Node;
            getFirstDescendant<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
            ): T | undefined;
            getFirstDescendant(
                condition?: (node: Node) => boolean,
            ): Node<Node> | undefined;
            getFirstDescendantByKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getFirstDescendantByKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getFirstDescendantOrThrow<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
                message?: string | (() => string),
            ): T;
            getFirstDescendantOrThrow(
                condition?: (node: Node) => boolean,
                message?: string | (() => string),
            ): Node;
            getFlags(): NodeFlags;
            getFullStart(): number;
            getFullText(): string;
            getFullWidth(): number;
            getIndentationLevel(): number;
            getIndentationText(offset?: number): string;
            getKind(): SyntaxKind;
            getKindName(): string;
            getLastChild<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
            ): T | undefined;
            getLastChild(condition?: (node: Node) => boolean): Node<Node> | undefined;
            getLastChildByKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getLastChildByKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getLastChildIfKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getLastChildIfKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getLastChildOrThrow<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
                message?: string | (() => string),
            ): T;
            getLastChildOrThrow(
                condition?: (node: Node) => boolean,
                message?: string | (() => string),
            ): Node;
            getLastToken(): Node;
            getLeadingCommentRanges(): CommentRange[];
            getLeadingTriviaWidth(): number;
            getLocal(name: string): Symbol | undefined;
            getLocalOrThrow(name: string, message?: string | (() => string)): Symbol;
            getLocals(): Symbol[];
            getNextSibling<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
            ): T | undefined;
            getNextSibling(condition?: (node: Node) => boolean): Node<Node> | undefined;
            getNextSiblingIfKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getNextSiblingIfKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getNextSiblingOrThrow<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
                message?: string | (() => string),
            ): T;
            getNextSiblingOrThrow(
                condition?: (node: Node) => boolean,
                message?: string | (() => string),
            ): Node;
            getNextSiblings(): Node<Node>[];
            getNodeProperty<
                KeyType extends string
                | number
                | symbol,
                LocalNodeType extends Node = Node,
            >(
                propertyName: KeyType,
            ): NodePropertyToWrappedType<LocalNodeType, KeyType>;
            getNonWhitespaceStart(): number;
            getParent(): Node<Node> | undefined;
            getParentIf<T extends Node<Node>>(
                condition: (parent: Node<Node> | undefined, node: Node) => parent is T,
            ): T | undefined;
            getParentIf(
                condition: (parent: Node<Node> | undefined, node: Node) => boolean,
            ): Node<Node> | undefined;
            getParentIfKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getParentIfKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getParentIfOrThrow<T extends Node<Node>>(
                condition: (parent: Node<Node> | undefined, node: Node) => parent is T,
                message?: string | (() => string),
            ): T;
            getParentIfOrThrow(
                condition: (parent: Node<Node> | undefined, node: Node) => boolean,
                message?: string | (() => string),
            ): Node;
            getParentOrThrow(message?: string | (() => string)): Node<Node>;
            getParentSyntaxList(): SyntaxList | undefined;
            getParentSyntaxListOrThrow(message?: string | (() => string)): SyntaxList;
            getParentWhile<T extends Node<Node>>(
                condition: (parent: Node, child: Node) => parent is T,
            ): T | undefined;
            getParentWhile(
                condition: (parent: Node, child: Node) => boolean,
            ): Node<Node> | undefined;
            getParentWhileKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getParentWhileKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getParentWhileOrThrow<T extends Node<Node>>(
                condition: (parent: Node, node: Node) => parent is T,
                message?: string | (() => string),
            ): T;
            getParentWhileOrThrow(
                condition: (parent: Node, node: Node) => boolean,
                message?: string | (() => string),
            ): Node;
            getPos(): number;
            getPreviousSibling<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
            ): T | undefined;
            getPreviousSibling(
                condition?: (node: Node) => boolean,
            ): Node<Node> | undefined;
            getPreviousSiblingIfKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): KindToNodeMappings[TKind] | undefined;
            getPreviousSiblingIfKindOrThrow<TKind extends SyntaxKind>(
                kind: TKind,
                message?: string | (() => string),
            ): KindToNodeMappings[TKind];
            getPreviousSiblingOrThrow<T extends Node<Node>>(
                condition?: (node: Node) => node is T,
                message?: string | (() => string),
            ): T;
            getPreviousSiblingOrThrow(
                condition?: (node: Node) => boolean,
                message?: string | (() => string),
            ): Node;
            getPreviousSiblings(): Node<Node>[];
            getProject(): Project;
            getSourceFile(): SourceFile;
            getStart(includeJsDocComments?: boolean): number;
            getStartLineNumber(includeJsDocComments?: boolean): number;
            getStartLinePos(includeJsDocComments?: boolean): number;
            getSymbol(): Symbol | undefined;
            getSymbolOrThrow(message?: string | (() => string)): Symbol;
            getSymbolsInScope(meaning: SymbolFlags): Symbol[];
            getText(includeJsDocComments?: boolean): string;
            getText(
                options: {
                    includeJsDocComments?: boolean;
                    trimLeadingIndentation?: boolean;
                },
            ): string;
            getTrailingCommentRanges(): CommentRange[];
            getTrailingTriviaEnd(): number;
            getTrailingTriviaWidth(): number;
            getType(): Type;
            getWidth(includeJsDocComments?: boolean): number;
            isFirstNodeOnLine(): boolean;
            isInStringAtPos(pos: number): boolean;
            isInSyntaxList(): boolean;
            isKind<TKind extends SyntaxKind>(
                kind: TKind,
            ): this is KindToNodeMappings[TKind];
            prependWhitespace(textOrWriterFunction: string | WriterFunction): void;
            print(options?: PrintNodeOptions): string;
            replaceWithText(textOrWriterFunction: string | WriterFunction): Node;
            transform(visitNode: (traversal: TransformTraversalControl) => Node): Node;
            wasForgotten(): boolean;
        }
        • compilerNode: {
              end: number;
              flags: NodeFlags;
              kind: SyntaxKind;
              parent: { readonly kind: SyntaxKind; readonly flags: NodeFlags; readonly parent: ...; readonly getSourceFile: () => SourceFile; readonly getChildCount: (sourceFile?: SourceFile | undefined) => number; ... 14 more ...; readonly end: number; };
              pos: number;
              forEachChild<T>(
                  cbNode: (node: Node) => T | undefined,
                  cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined,
              ): T | undefined;
              getChildAt(index: number, sourceFile?: SourceFile): Node;
              getChildCount(sourceFile?: SourceFile): number;
              getChildren(sourceFile?: SourceFile): readonly Node[];
              getEnd(): number;
              getFirstToken(sourceFile?: SourceFile): Node | undefined;
              getFullStart(): number;
              getFullText(sourceFile?: SourceFile): string;
              getFullWidth(): number;
              getLastToken(sourceFile?: SourceFile): Node | undefined;
              getLeadingTriviaWidth(sourceFile?: SourceFile): number;
              getSourceFile(): SourceFile;
              getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
              getText(sourceFile?: SourceFile): string;
              getWidth(sourceFile?: SourceFileLike): number;
          }
        • appendWhitespace: function
          • Appends the specified whitespace to current node.

            Parameters

            • textOrWriterFunction: string | WriterFunction

              Text or writer function.

            Returns void

        • asKind: function
          • Gets the node as the specified kind if it is equal to that kind, otherwise returns undefined.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind] | undefined

        • asKindOrThrow: function
          • Gets the node as the specified kind if it is equal to that kind, otherwise throws.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • containsRange: function
          • If the node contains the provided range (inclusive).

            Parameters

            • pos: number

              Start position.

            • end: number

              End position.

            Returns boolean

        • forEachChild: function
          • Invokes the cbNode callback for each child and the cbNodeArray for every array of nodes stored in properties of the node. If cbNodeArray is not defined, then it will pass every element of the array to cbNode.

            Type Parameters

            • T

            Parameters

            • cbNode: (node: Node) => T | undefined

              Callback invoked for each child.

            • OptionalcbNodeArray: (nodes: Node<Node>[]) => T | undefined

              Callback invoked for each array of nodes.

            Returns T | undefined

            The first truthy value returned by a callback.

        • forEachChildAsArray: function
          • Gets the child nodes passed to the delegate of node.forEachChild(child => {}) as an array.

            Returns Node<Node>[]

        • forEachDescendant: function
          • Invokes the cbNode callback for each descendant and the cbNodeArray for every array of nodes stored in properties of the node and descendant nodes. If cbNodeArray is not defined, then it will pass every element of the array to cbNode.

            Type Parameters

            • T

            Parameters

            • cbNode: (node: Node, traversal: ForEachDescendantTraversalControl) => T | undefined

              Callback invoked for each descendant.

            • OptionalcbNodeArray: (
                  nodes: Node<Node>[],
                  traversal: ForEachDescendantTraversalControl,
              ) => T | undefined

              Callback invoked for each array of nodes.

            Returns T | undefined

            The first truthy value returned by a callback.

            There exists a traversal object on the second parameter that allows various control of iteration.

        • forEachDescendantAsArray: function
          • Gets the descendant nodes passed to the delegate of node.forEachDescendant(descendant => {}) as an array.

            Returns Node<Node>[]

        • forget: function
          • 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.

            Returns void

        • forgetDescendants: function
          • Forgets the descendants of this node.

            Returns void

        • formatText: function
          • Formats the node's text using the internal TypeScript formatting API.

            Parameters

            • Optionalsettings: FormatCodeSettings

              Format code settings.

            Returns void

        • getAncestors: function
          • Goes up the tree getting all the parents in ascending order.

            Returns Node<Node>[]

        • getChildAtIndex: function
          • Gets the child at the specified index.

            Parameters

            • index: number

              Index of the child.

            Returns Node

        • getChildAtIndexIfKind: function
          • Gets the child at the specified index if it's the specified kind or returns undefined.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • index: number

              Child index to get.

            • kind: TKind

              Expected kind.

            Returns KindToNodeMappings[TKind] | undefined

        • getChildAtIndexIfKindOrThrow: function
          • Gets the child at the specified index if it's the specified kind or throws an exception.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • index: number

              Child index to get.

            • kind: TKind

              Expected kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getChildAtPos: function
          • Gets the child at the provided text position, or undefined if not found.

            Parameters

            • pos: number

              Text position to search for.

            Returns Node<Node> | undefined

        • getChildCount: function
          • Gets the number of children the node has.

            Returns number

        • getChildIndentationLevel: function
          • Gets the child indentation level of the current node.

            Returns number

        • getChildIndentationText: function
          • Gets the next indentation level text.

            Parameters

            • Optionaloffset: number

              Optional number of levels of indentation to add or remove.

            Returns string

        • getChildIndex: function
          • Gets the child index of this node relative to the parent.

            Returns number

        • getChildren: function
          • Gets all the children of the node.

            Returns Node<Node>[]

        • getChildrenOfKind: function
          • Gets the children based on a kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind][]

        • getChildSyntaxList: function
          • Gets the child syntax list if it exists.

            Returns SyntaxList | undefined

        • getChildSyntaxListOrThrow: function
          • Gets the child syntax list or throws if it doesn't exist.

            Parameters

            • Optionalmessage: string | (() => string)

            Returns SyntaxList

        • getCombinedModifierFlags: function
          • Gets the combined modifier flags.

            Returns ModifierFlags

        • getDescendantAtPos: function
          • Gets the most specific descendant at the provided text position, or undefined if not found.

            Parameters

            • pos: number

              Text position to search for.

            Returns Node<Node> | undefined

        • getDescendantAtStartWithWidth: function
          • Gets the most specific descendant at the provided start text position with the specified width, or undefined if not found.

            Parameters

            • start: number

              Start text position to search for.

            • width: number

              Text length of the node to search for.

            Returns Node<Node> | undefined

        • getDescendants: function
          • Gets the node's descendants.

            Returns Node<Node>[]

        • getDescendantsOfKind: function
          • Gets the descendants that match a specified syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Kind to check.

            Returns KindToNodeMappings[TKind][]

        • getDescendantStatements: function
          • Gets the node's descendant statements and any arrow function statement-like expressions (ex. returns the expression 5 in () => 5).

            Returns (Expression<Expression> | Statement<Statement>)[]

        • getEnd: function
          • Gets the source file text position where the node ends.

            Returns number

            This does not include the following trivia (comments and whitespace).

        • getEndLineNumber: function
          • Gets the line number of the end of the node.

            Returns number

        • getFirstAncestor: function
          • Gets the first ancestor that matches the provided condition or returns undefined if not found.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition to match.

            Returns T | undefined

          • Gets the first ancestor that matches the provided condition or returns undefined if not found.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition to match.

            Returns Node<Node> | undefined

        • getFirstAncestorByKind: function
          • Get the first ancestor by syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind] | undefined

        • getFirstAncestorByKindOrThrow: function
          • Gets the first ancestor by syntax kind or throws if not found.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getFirstAncestorOrThrow: function
          • Gets the first ancestor that matches the provided condition or throws if not found.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition to match.

            Returns T

          • Gets the first ancestor that matches the provided condition or throws if not found.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition to match.

            Returns Node

        • getFirstChild: function
          • Gets the first child by a condition.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition.

            Returns T | undefined

          • Gets the first child by a condition.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition.

            Returns Node<Node> | undefined

        • getFirstChildByKind: function
          • Gets the first child by syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind] | undefined

        • getFirstChildByKindOrThrow: function
          • Gets the first child by syntax kind or throws an error if not found.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getFirstChildIfKind: function
          • Gets the first child if it matches the specified syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind] | undefined

        • getFirstChildIfKindOrThrow: function
          • Gets the first child if it matches the specified syntax kind or throws an error if not found.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getFirstChildOrThrow: function
          • Gets the first child by a condition or throws.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition.

            • Optionalmessage: string | (() => string)

            Returns T

          • Gets the first child by a condition or throws.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition.

            • Optionalmessage: string | (() => string)

            Returns Node

        • getFirstDescendant: function
          • Gets the first descendant by a condition.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition.

            Returns T | undefined

          • Gets the first descendant by a condition.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition.

            Returns Node<Node> | undefined

        • getFirstDescendantByKind: function
          • Gets the first descendant by syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind] | undefined

        • getFirstDescendantByKindOrThrow: function
          • Gets the first descendant by syntax kind or throws.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getFirstDescendantOrThrow: function
          • Gets the first descendant by a condition or throws.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition.

            • Optionalmessage: string | (() => string)

            Returns T

          • Gets the first descendant by a condition or throws.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition.

            • Optionalmessage: string | (() => string)

            Returns Node

        • getFlags: function
          • Gets the node's flags.

            Returns NodeFlags

        • getFullStart: function
          • Gets the source file text position of the end of the last significant token or the start of the source file.

            Returns number

        • getFullText: function
          • Gets the full text with leading trivia (comments and whitespace).

            Returns string

        • getFullWidth: function
          • Gets the text length of the node with trivia.

            Returns number

        • getIndentationLevel: function
          • Gets the indentation level of the current node.

            Returns number

        • getIndentationText: function
          • Gets the indentation text.

            Parameters

            • Optionaloffset: number

              Optional number of levels of indentation to add or remove.

            Returns string

        • getKind: function
          • Gets the syntax kind.

            Returns SyntaxKind

        • getKindName: function
          • Gets the syntax kind name.

            Returns string

        • getLastChild: function
          • Gets the last child by a condition.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition.

            Returns T | undefined

          • Gets the last child by a condition.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition.

            Returns Node<Node> | undefined

        • getLastChildByKind: function
          • Gets the last child by syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind] | undefined

        • getLastChildByKindOrThrow: function
          • Gets the last child by syntax kind or throws an error if not found.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getLastChildIfKind: function
          • Gets the last child if it matches the specified syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns KindToNodeMappings[TKind] | undefined

        • getLastChildIfKindOrThrow: function
          • Gets the last child if it matches the specified syntax kind or throws an error if not found.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getLastChildOrThrow: function
          • Gets the last child by a condition or throws.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Condition.

            • Optionalmessage: string | (() => string)

            Returns T

          • Gets the last child by a condition or throws.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Condition.

            • Optionalmessage: string | (() => string)

            Returns Node

        • getLastToken: function
          • Gets the last token of this node. Usually this is a close brace.

            Returns Node

        • getLeadingCommentRanges: function
          • Gets the leading comment ranges of the current node.

            Returns CommentRange[]

        • getLeadingTriviaWidth: function
          • Gets the node's leading trivia's text length.

            Returns number

        • getLocal: function
          • Gets the specified local symbol by name or returns undefined if it doesn't exist.

            WARNING: The symbol table of locals is not exposed publicly by the compiler. Use this at your own risk knowing it may break.

            Parameters

            • name: string

              Name of the local symbol.

            Returns Symbol | undefined

        • getLocalOrThrow: function
          • Gets the specified local symbol by name or throws if it doesn't exist.

            WARNING: The symbol table of locals is not exposed publicly by the compiler. Use this at your own risk knowing it may break.

            Parameters

            • name: string

              Name of the local symbol.

            • Optionalmessage: string | (() => string)

            Returns Symbol

        • getLocals: function
          • Gets the symbols within the current scope.

            WARNING: The symbol table of locals is not exposed publicly by the compiler. Use this at your own risk knowing it may break.

            Returns Symbol[]

        • getNextSibling: function
          • Gets the next sibling.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Optional condition for getting the next sibling.

            Returns T | undefined

          • Gets the next sibling.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Optional condition for getting the next sibling.

            Returns Node<Node> | undefined

        • getNextSiblingIfKind: function
          • Gets the next sibling if it matches the specified kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Kind to check.

            Returns KindToNodeMappings[TKind] | undefined

        • getNextSiblingIfKindOrThrow: function
          • Gets the next sibiling if it matches the specified kind, or throws.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Kind to check.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getNextSiblingOrThrow: function
          • Gets the next sibling or throws.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Optional condition for getting the next sibling.

            • Optionalmessage: string | (() => string)

            Returns T

          • Gets the next sibling or throws.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Optional condition for getting the next sibling.

            • Optionalmessage: string | (() => string)

            Returns Node

        • getNextSiblings: function
          • Gets the next siblings.

            Note: Closest sibling is the zero index.

            Returns Node<Node>[]

        • getNodeProperty: function
          • Gets a compiler node property wrapped in a Node.

            Type Parameters

            • KeyType extends string | number | symbol
            • LocalNodeType extends Node = Node

            Parameters

            • propertyName: KeyType

              Property name.

            Returns NodePropertyToWrappedType<LocalNodeType, KeyType>

        • getNonWhitespaceStart: function
          • Gets the first source file text position that is not whitespace taking into account comment nodes and a previous node's trailing trivia.

            Returns number

        • getParent: function
          • Get the node's parent.

            Returns Node<Node> | undefined

        • getParentIf: function
          • Gets the parent if it matches a certain condition.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • condition: (parent: Node<Node> | undefined, node: Node) => parent is T

            Returns T | undefined

          • Gets the parent if it matches a certain condition.

            Parameters

            • condition: (parent: Node<Node> | undefined, node: Node) => boolean

            Returns Node<Node> | undefined

        • getParentIfKind: function
          • Gets the parent if it's a certain syntax kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

            Returns KindToNodeMappings[TKind] | undefined

        • getParentIfKindOrThrow: function
          • Gets the parent if it's a certain syntax kind or throws.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind
            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getParentIfOrThrow: function
          • Gets the parent if it matches a certain condition or throws.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • condition: (parent: Node<Node> | undefined, node: Node) => parent is T
            • Optionalmessage: string | (() => string)

            Returns T

          • Gets the parent if it matches a certain condition or throws.

            Parameters

            • condition: (parent: Node<Node> | undefined, node: Node) => boolean
            • Optionalmessage: string | (() => string)

            Returns Node

        • getParentOrThrow: function
          • Gets the parent or throws an error if it doesn't exist.

            Parameters

            • Optionalmessage: string | (() => string)

            Returns Node<Node>

        • getParentSyntaxList: function
          • Gets the parent if it's a syntax list.

            Returns SyntaxList | undefined

        • getParentSyntaxListOrThrow: function
          • Gets the parent if it's a syntax list or throws an error otherwise.

            Parameters

            • Optionalmessage: string | (() => string)

            Returns SyntaxList

        • getParentWhile: function
          • Goes up the parents (ancestors) of the node while a condition is true. Returns undefined if the initial parent doesn't match the condition.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • condition: (parent: Node, child: Node) => parent is T

              Condition that tests the parent to see if the expression is true.

            Returns T | undefined

          • Goes up the parents (ancestors) of the node while a condition is true. Returns undefined if the initial parent doesn't match the condition.

            Parameters

            • condition: (parent: Node, child: Node) => boolean

              Condition that tests the parent to see if the expression is true.

            Returns Node<Node> | undefined

        • getParentWhileKind: function
          • 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.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind to check for.

            Returns KindToNodeMappings[TKind] | undefined

        • getParentWhileKindOrThrow: function
          • 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.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind to check for.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getParentWhileOrThrow: function
          • Goes up the parents (ancestors) of the node while a condition is true. Throws if the initial parent doesn't match the condition.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • condition: (parent: Node, node: Node) => parent is T

              Condition that tests the parent to see if the expression is true.

            • Optionalmessage: string | (() => string)

            Returns T

          • Goes up the parents (ancestors) of the node while a condition is true. Throws if the initial parent doesn't match the condition.

            Parameters

            • condition: (parent: Node, node: Node) => boolean

              Condition that tests the parent to see if the expression is true.

            • Optionalmessage: string | (() => string)

            Returns Node

        • getPos: function
          • Gets the source file text position where the node starts that includes the leading trivia (comments and whitespace).

            Returns number

        • getPreviousSibling: function
          • Gets the previous sibling.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Optional condition for getting the previous sibling.

            Returns T | undefined

          • Gets the previous sibling.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Optional condition for getting the previous sibling.

            Returns Node<Node> | undefined

        • getPreviousSiblingIfKind: function
          • Gets the previous sibling if it matches the specified kind.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Kind to check.

            Returns KindToNodeMappings[TKind] | undefined

        • getPreviousSiblingIfKindOrThrow: function
          • Gets the previous sibiling if it matches the specified kind, or throws.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Kind to check.

            • Optionalmessage: string | (() => string)

            Returns KindToNodeMappings[TKind]

        • getPreviousSiblingOrThrow: function
          • Gets the previous sibling or throws.

            Type Parameters

            • T extends Node<Node>

            Parameters

            • Optionalcondition: (node: Node) => node is T

              Optional condition for getting the previous sibling.

            • Optionalmessage: string | (() => string)

            Returns T

          • Gets the previous sibling or throws.

            Parameters

            • Optionalcondition: (node: Node) => boolean

              Optional condition for getting the previous sibling.

            • Optionalmessage: string | (() => string)

            Returns Node

        • getPreviousSiblings: function
          • Gets the previous siblings.

            Note: Closest sibling is the zero index.

            Returns Node<Node>[]

        • getProject: function
          • Gets the project.

            Returns Project

        • getSourceFile: function
          • Gets the source file.

            Returns SourceFile

        • getStart: function
          • Gets the source file text position where the node starts that does not include the leading trivia (comments and whitespace).

            Parameters

            • OptionalincludeJsDocComments: boolean

              Whether to include the JS doc comments.

            Returns number

        • getStartLineNumber: function
          • Gets the line number at the start of the node.

            Parameters

            • OptionalincludeJsDocComments: boolean

              Whether to include the JS doc comments or not.

            Returns number

        • getStartLinePos: function
          • Gets the position of the start of the line that this node starts on.

            Parameters

            • OptionalincludeJsDocComments: boolean

              Whether to include the JS doc comments or not.

            Returns number

        • getSymbol: function
          • Gets the compiler symbol or undefined if it doesn't exist.

            Returns Symbol | undefined

        • getSymbolOrThrow: function
          • Gets the symbol or throws an error if it doesn't exist.

            Parameters

            • Optionalmessage: string | (() => string)

            Returns Symbol

        • getSymbolsInScope: function
          • Gets the symbols in the scope of the node.

            Note: This will always return the local symbols. If you want the export symbol from a local symbol, then use the #getExportSymbol() method on the symbol.

            Parameters

            • meaning: SymbolFlags

              Meaning of symbol to filter by.

            Returns Symbol[]

        • getText: function
          • Gets the text without leading trivia (comments and whitespace).

            Parameters

            • OptionalincludeJsDocComments: boolean

              Whether to include the js doc comments when getting the text.

            Returns string

          • Gets the text without leading trivia (comments and whitespace).

            Parameters

            • options: { includeJsDocComments?: boolean; trimLeadingIndentation?: boolean }

              Options for getting the text.

            Returns string

        • getTrailingCommentRanges: function
          • Gets the trailing comment ranges of the current node.

            Returns CommentRange[]

        • getTrailingTriviaEnd: function
          • Gets the text position of the next significant token or new line.

            Returns number

        • getTrailingTriviaWidth: function
          • Gets the text length from the end of the current node to the next significant token or new line.

            Returns number

        • getType: function
          • Gets the type of the node.

            Returns Type

        • getWidth: function
          • Gets the text length of the node without trivia.

            Parameters

            • OptionalincludeJsDocComments: boolean

              Whether to include the JS doc comments in the width or not.

            Returns number

        • isFirstNodeOnLine: function
          • Gets if this is the first node on the current line.

            Returns boolean

        • isInStringAtPos: function
          • Gets if the specified position is within a string.

            Parameters

            • pos: number

              Position.

            Returns boolean

        • isInSyntaxList: function
          • Gets if this node is in a syntax list.

            Returns boolean

        • isKind: function
          • Returns if the node is the specified kind.

            This is a type guard.

            Type Parameters

            • TKind extends SyntaxKind

            Parameters

            • kind: TKind

              Syntax kind.

            Returns this is KindToNodeMappings[TKind]

        • prependWhitespace: function
          • Prepends the specified whitespace to current node.

            Parameters

            • textOrWriterFunction: string | WriterFunction

              Text or writer function.

            Returns void

        • print: function
          • Prints the node using the compiler's printer.

            Parameters

            • Optionaloptions: PrintNodeOptions

              Options.

            Returns string

        • replaceWithText: function
          • Replaces the text of the current node with new text.

            This will forget the current node and return a new node that can be asserted or type guarded to the correct type.

            Parameters

            • textOrWriterFunction: string | WriterFunction

              Text or writer function to replace with.

            Returns Node

            The new node.

            This will replace the text from the Node#getStart(true) position (start position with js docs) to Node#getEnd(). Use Node#getText(true) to get all the text that will be replaced.

        • transform: function
          • Transforms the node using the compiler api nodes and functions and returns the node that was transformed (experimental).

            WARNING: This will forget descendants of transformed nodes and potentially this node.

            Parameters

            • visitNode: (traversal: TransformTraversalControl) => Node

            Returns Node

            sourceFile.transform(traversal => {
            const node = traversal.visitChildren(); // recommend always visiting the children first (post order)
            if (ts.isNumericLiteral(node))
            return ts.createNumericLiteral((parseInt(node.text, 10) + 1).toString());
            return node;
            });
            const classDec = sourceFile.getClassOrThrow("MyClass");
            classDec.transform(traversal => {
            const node = traversal.currentNode;
            return ts.updateClassDeclaration(node, undefined, undefined, ts.createIdentifier("MyUpdatedClass"), undefined, undefined, []);
            });
        • wasForgotten: function
          • Gets if the compiler node was forgotten.

            This will be true when the compiler node was forgotten or removed.

            Returns boolean

      Returns node is ReadonlyArrayTypeNode