Static ReadonlyisStatic ReadonlyisGets if the node is an ArrayBindingPattern.
Static ReadonlyisGets if the node is an ArrayLiteralExpression.
Static ReadonlyisGets if the node is an ArrowFunction.
Static ReadonlyisGets if the node is an AsExpression.
Static ReadonlyisGets if the node is an AwaitExpression.
Static ReadonlyisGets if the node is a BigIntLiteral.
Static ReadonlyisGets if the node is a BinaryExpression.
Static ReadonlyisGets if the node is a BindingElement.
Static ReadonlyisGets if the node is a Block.
Static ReadonlyisGets if the node is a BooleanKeyword.
Static ReadonlyisGets if the node is a BreakStatement.
Static ReadonlyisGets if the node is a CallExpression.
Static ReadonlyisGets if the node is a CaseBlock.
Static ReadonlyisGets if the node is a CaseClause.
Static ReadonlyisGets if the node is a CatchClause.
Static ReadonlyisGets if the node is a ClassDeclaration.
Static ReadonlyisGets if the node is a ClassExpression.
Static ReadonlyisGets if the node is a ClassStaticBlockDeclaration.
Static ReadonlyisGets if the node is a CommaListExpression.
Static ReadonlyisGets if the node is a ComputedPropertyName.
Static ReadonlyisGets if the node is a ConditionalExpression.
Static ReadonlyisGets if the node is a ContinueStatement.
Static ReadonlyisGets if the node is a DebuggerStatement.
Static ReadonlyisGets if the node is a Decorator.
Static ReadonlyisGets if the node is a DefaultClause.
Static ReadonlyisGets if the node is a DeleteExpression.
Static ReadonlyisGets if the node is a DoStatement.
Static ReadonlyisGets if the node is an ElementAccessExpression.
Static ReadonlyisGets if the node is an EmptyStatement.
Static ReadonlyisGets if the node is an EnumDeclaration.
Static ReadonlyisGets if the node is an EnumMember.
Static ReadonlyisGets if the node is an ExportAssignment.
Static ReadonlyisGets if the node is an ExportDeclaration.
Static ReadonlyisGets if the node is an ExportSpecifier.
Static ReadonlyisGets if the node is an ExpressionStatement.
Static ReadonlyisGets if the node is an ExpressionWithTypeArguments.
Static ReadonlyisGets if the node is an ExternalModuleReference.
Static ReadonlyisGets if the node is a ForInStatement.
Static ReadonlyisGets if the node is a ForOfStatement.
Static ReadonlyisGets if the node is a ForStatement.
Static ReadonlyisGets if the node is a FunctionDeclaration.
Static ReadonlyisGets if the node is a FunctionExpression.
Static ReadonlyisGets if the node is a HeritageClause.
Static ReadonlyisGets if the node is a Identifier.
Static ReadonlyisGets if the node is a IfStatement.
Static ReadonlyisGets if the node is a ImportAttribute.
Static ReadonlyisGets if the node is a ImportAttributes.
Static ReadonlyisGets if the node is a ImportClause.
Static ReadonlyisGets if the node is a ImportDeclaration.
Static ReadonlyisGets if the node is a ImportEqualsDeclaration.
Static ReadonlyisGets if the node is a ImportSpecifier.
Static ReadonlyisGets if the node is a InferKeyword.
Static ReadonlyisGets if the node is a InterfaceDeclaration.
Static ReadonlyisGets if the node is a JSDoc.
Static ReadonlyisGets if the node is a JSDocAllType.
Static ReadonlyisGets if the node is a JSDocAugmentsTag.
Static ReadonlyisGets if the node is a JSDocAuthorTag.
Static ReadonlyisGets if the node is a JSDocCallbackTag.
Static ReadonlyisGets if the node is a JSDocClassTag.
Static ReadonlyisGets if the node is a JSDocDeprecatedTag.
Static ReadonlyisGets if the node is a JSDocEnumTag.
Static ReadonlyisGets if the node is a JSDocFunctionType.
Static ReadonlyisGets if the node is a JSDocImplementsTag.
Static ReadonlyisGets if the node is a JSDocLink.
Static ReadonlyisGets if the node is a JSDocLinkCode.
Static ReadonlyisGets if the node is a JSDocLinkPlain.
Static ReadonlyisGets if the node is a JSDocMemberName.
Static ReadonlyisGets if the node is a JSDocNamepathType.
Static ReadonlyisGets if the node is a JSDocNameReference.
Static ReadonlyisGets if the node is a JSDocNonNullableType.
Static ReadonlyisGets if the node is a JSDocNullableType.
Static ReadonlyisGets if the node is a JSDocOptionalType.
Static ReadonlyisGets if the node is a JSDocOverloadTag.
Static ReadonlyisGets if the node is a JSDocOverrideTag.
Static ReadonlyisGets if the node is a JSDocParameterTag.
Static ReadonlyisGets if the node is a JSDocPrivateTag.
Static ReadonlyisGets if the node is a JSDocPropertyTag.
Static ReadonlyisGets if the node is a JSDocProtectedTag.
Static ReadonlyisGets if the node is a JSDocPublicTag.
Static ReadonlyisGets if the node is a JSDocReadonlyTag.
Static ReadonlyisGets if the node is a JSDocReturnTag.
Static ReadonlyisGets if the node is a JSDocSatisfiesTag.
Static ReadonlyisGets if the node is a JSDocSeeTag.
Static ReadonlyisGets if the node is a JSDocSignature.
Static ReadonlyisGets if the node is a JSDocTemplateTag.
Static ReadonlyisGets if the node is a JSDocText.
Static ReadonlyisGets if the node is a JSDocThisTag.
Static ReadonlyisGets if the node is a JSDocThrowsTag.
Static ReadonlyisGets if the node is a JSDocTypedefTag.
Static ReadonlyisGets if the node is a JSDocTypeExpression.
Static ReadonlyisGets if the node is a JSDocTypeLiteral.
Static ReadonlyisGets if the node is a JSDocTypeTag.
Static ReadonlyisGets if the node is a JSDocUnknownType.
Static ReadonlyisGets if the node is a JSDocVariadicType.
Static ReadonlyisGets if the node is a JsxAttribute.
Static ReadonlyisGets if the node is a JsxClosingElement.
Static ReadonlyisGets if the node is a JsxClosingFragment.
Static ReadonlyisGets if the node is a JsxElement.
Static ReadonlyisGets if the node is a JsxExpression.
Static ReadonlyisGets if the node is a JsxFragment.
Static ReadonlyisGets if the node is a JsxNamespacedName.
Static ReadonlyisGets if the node is a JsxOpeningElement.
Static ReadonlyisGets if the node is a JsxOpeningFragment.
Static ReadonlyisGets if the node is a JsxSelfClosingElement.
Static ReadonlyisGets if the node is a JsxSpreadAttribute.
Static ReadonlyisGets if the node is a JsxText.
Static ReadonlyisGets if the node is a LabeledStatement.
Static ReadonlyisGets if the node is a MetaProperty.
Static ReadonlyisGets if the node is a MethodDeclaration.
Static ReadonlyisGets if the node is a MethodSignature.
Static ReadonlyisGets if the node is a ModuleBlock.
Static ReadonlyisGets if the node is a ModuleDeclaration.
Static ReadonlyisGets if the node is a NamedExports.
Static ReadonlyisGets if the node is a NamedImports.
Static ReadonlyisGets if the node is a NamedTupleMember.
Static ReadonlyisGets if the node is a NamespaceExport.
Static ReadonlyisGets if the node is a NamespaceImport.
Static ReadonlyisGets if the node is a NeverKeyword.
Static ReadonlyisGets if the node is a NewExpression.
Static ReadonlyisGets if the node is a NonNullExpression.
Static ReadonlyisGets if the node is a NoSubstitutionTemplateLiteral.
Static ReadonlyisGets if the node is a NotEmittedStatement.
Static ReadonlyisGets if the node is a NumberKeyword.
Static ReadonlyisGets if the node is a NumericLiteral.
Static ReadonlyisGets if the node is a ObjectBindingPattern.
Static ReadonlyisGets if the node is a ObjectKeyword.
Static ReadonlyisGets if the node is a ObjectLiteralExpression.
Static ReadonlyisGets if the node is a OmittedExpression.
Static ReadonlyisGets if the node is a ParenthesizedExpression.
Static ReadonlyisGets if the node is a PartiallyEmittedExpression.
Static ReadonlyisGets if the node is a PostfixUnaryExpression.
Static ReadonlyisGets if the node is a PrefixUnaryExpression.
Static ReadonlyisGets if the node is a PrivateIdentifier.
Static ReadonlyisGets if the node is a PropertyAccessExpression.
Static ReadonlyisGets if the node is a PropertyAssignment.
Static ReadonlyisGets if the node is a PropertyDeclaration.
Static ReadonlyisGets if the node is a PropertySignature.
Static ReadonlyisGets if the node is a QualifiedName.
Static ReadonlyisGets if the node is a RegularExpressionLiteral.
Static ReadonlyisGets if the node is a ReturnStatement.
Static ReadonlyisGets if the node is a SatisfiesExpression.
Static ReadonlyisGets if the node is a SemicolonToken.
Static ReadonlyisGets if the node is a ShorthandPropertyAssignment.
Static ReadonlyisGets if the node is a SourceFile.
Static ReadonlyisGets if the node is a SpreadAssignment.
Static ReadonlyisGets if the node is a SpreadElement.
Static ReadonlyisGets if the node is a StringKeyword.
Static ReadonlyisGets if the node is a StringLiteral.
Static ReadonlyisGets if the node is a SwitchStatement.
Static ReadonlyisGets if the node is a SymbolKeyword.
Static ReadonlyisGets if the node is a SyntaxList.
Static ReadonlyisGets if the node is a TaggedTemplateExpression.
Static ReadonlyisGets if the node is a TemplateExpression.
Static ReadonlyisGets if the node is a TemplateHead.
Static ReadonlyisGets if the node is a TemplateMiddle.
Static ReadonlyisGets if the node is a TemplateSpan.
Static ReadonlyisGets if the node is a TemplateTail.
Static ReadonlyisGets if the node is a ThrowStatement.
Static ReadonlyisGets if the node is a TryStatement.
Static ReadonlyisGets if the node is a TypeAliasDeclaration.
Static ReadonlyisGets if the node is a TypeOfExpression.
Static ReadonlyisGets if the node is a UndefinedKeyword.
Static ReadonlyisGets if the node is a VariableDeclaration.
Static ReadonlyisGets if the node is a VariableDeclarationList.
Static ReadonlyisGets if the node is a VariableStatement.
Static ReadonlyisGets if the node is a VoidExpression.
Static ReadonlyisGets if the node is a WhileStatement.
Static ReadonlyisGets if the node is a WithStatement.
Static ReadonlyisGets if the node is a YieldExpression.
Gets the underlying compiler node.
Adds an class declaration as a child.
Structure of the class declaration to add.
Adds class declarations as a child.
Structures of the class declarations to add.
Adds an enum declaration as a child.
Structure of the enum declaration to add.
Adds enum declarations as a child.
Structures of the enum declarations to add.
Add export assignments.
Structure that represents the export.
Add export assignments.
Structures that represent the exports.
Add export declarations.
Structure that represents the export.
Add export declarations.
Structures that represent the exports.
Adds a function declaration as a child.
Structure of the function declaration to add.
Adds function declarations as a child.
Structures of the function declarations to add.
Adds an import.
Structure that represents the import.
Adds imports.
Structures that represent the imports.
Adds a interface declaration as a child.
Structure of the interface declaration to add.
Adds interface declarations as a child.
Structures of the interface declarations to add.
Adds a module declaration as a child.
Structure of the namespace declaration to add.
Adds module declarations as a child.
Structures of the namespace declarations to add.
Add statements.
statements to add.
The statements that were added.
Adds a type alias declaration as a child.
Structure of the type alias declaration to add.
Adds type alias declarations as a child.
Structures of the type alias declarations to add.
Adds a variable statement.
Structure of the variable statement.
Adds variable statements.
Structures of the variable statements.
Appends the specified whitespace to current node.
Text or writer function.
Applies the text changes to the source file.
WARNING! This will forget all the nodes in the file! It's best to do this after you're all done with the file.
Text changes.
Gets the node as the specified kind if it is equal to that kind, otherwise returns undefined.
Syntax kind.
Gets the node as the specified kind if it is equal to that kind, otherwise throws.
Syntax kind.
Optionalmessage: string | (() => string)If the node contains the provided range (inclusive).
Start position.
End position.
Copy this source file to a new file.
This will modify the module specifiers in the new file, if necessary.
New file path. Can be relative to the original file or an absolute path.
Optionaloptions: SourceFileCopyOptionsOptions for copying.
Copy this source file to a new file and immediately saves it to the file system asynchronously.
This will modify the module specifiers in the new file, if necessary.
New file path. Can be relative to the original file or an absolute path.
Optionaloptions: SourceFileCopyOptionsOptions for copying.
Copy this source file to a new file and immediately saves it to the file system synchronously.
This will modify the module specifiers in the new file, if necessary.
New file path. Can be relative to the original file or an absolute path.
Optionaloptions: SourceFileCopyOptionsOptions for copying.
Copies this source file to the specified directory.
This will modify the module specifiers in the new file, if necessary.
Directory path or directory object to copy the file to.
Optionaloptions: SourceFileCopyOptionsOptions for copying.
The source file the copy was made to.
Queues a deletion of the file to the file system.
The file will be deleted when you call ast.save(). If you wish to immediately delete the file, then use deleteImmediately().
Asynchronously deletes the file from the file system.
Synchronously deletes the file from the file system.
Asynchronously emits the source file as a JavaScript file.
Optionaloptions: SourceFileEmitOptionsSynchronously emits the source file as a JavaScript file.
Optionaloptions: SourceFileEmitOptionsCode fix to add import declarations for identifiers that are referenced, but not imported in the source file.
OptionalformatSettings: FormatCodeSettingsFormat code settings.
OptionaluserPreferences: UserPreferencesUser preferences for refactoring.
Removes all unused declarations like interfaces, classes, enums, functions, variables, parameters, methods, properties, imports, etc. from this file.
Tip: For optimal results, sometimes this method needs to be called more than once. There could be nodes that are only referenced in unused declarations and in this case, another call will also remove them.
WARNING! This will forget all the nodes in the file! It's best to do this after you're all done with the file.
OptionalformatSettings: FormatCodeSettingsFormat code settings.
OptionaluserPreferences: UserPreferencesUser preferences for refactoring.
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.
The first truthy value returned by a callback.
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.
Callback invoked for each descendant.
OptionalcbNodeArray: (Callback invoked for each array of nodes.
The first truthy value returned by a callback.
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.
Forgets the descendants of this node.
Formats the source file text using the internal TypeScript formatting API.
Optionalsettings: FormatCodeSettingsFormat code settings.
Gets the file path's base name.
Gets the file path's base name without the extension.
Gets the child at the specified index if it's the specified kind or returns undefined.
Child index to get.
Expected kind.
Gets the child at the specified index if it's the specified kind or throws an exception.
Child index to get.
Expected kind.
Optionalmessage: string | (() => string)Gets the number of children the node has.
Gets the child indentation level of the current node.
Gets the next indentation level text.
Optionaloffset: numberOptional number of levels of indentation to add or remove.
Gets the child index of this node relative to the parent.
Gets the children based on a kind.
Syntax kind.
Gets the child syntax list if it exists.
Gets the child syntax list or throws if it doesn't exist.
Optionalmessage: string | (() => string)Gets a class.
Function to use to find the class.
Gets the direct class declaration children.
Gets a class or throws if it doesn't exist.
Name of the class.
Gets a class or throws if it doesn't exist.
Function to use to find the class.
Gets the combined modifier flags.
Gets the default export symbol.
Gets the default export symbol or throws if it doesn't exist.
Optionalmessage: string | (() => string)Gets the descendants that match a specified syntax kind.
Kind to check.
Gets the node's descendant statements and any arrow function statement-like expressions (ex. returns the expression 5 in () => 5).
Gets the directory that the source file is contained in.
Gets the directory path that the source file is contained in.
Gets the emit output of this source file.
Optionaloptions: { emitOnlyDtsFiles?: boolean }Emit options.
Gets the line number of the end of the node.
Gets an enum.
Function to use to find the enum.
Gets an enum or throws if it doesn't exist.
Name of the enum.
Gets an enum or throws if it doesn't exist.
Function to use to find the enum.
Gets the direct enum declaration children.
Gets the first export assignment that matches a condition, or undefined if it doesn't exist.
Condition to get the export assignment by.
Gets the first export assignment that matches a condition, or throws if it doesn't exist.
Condition to get the export assignment by.
Optionalmessage: string | (() => string)Get the file's export assignments.
Optionalmessage: string | (() => string)Gets the first export declaration that matches a module specifier, or undefined if it doesn't exist.
Gets the first export declaration that matches a condition, or throws if it doesn't exist.
Condition to get the export declaration by.
Optionalmessage: string | (() => string)Gets the first export declaration that matches a module specifier, or throws if it doesn't exist.
Optionalmessage: string | (() => string)Get the export declarations.
Gets all the declarations that are exported from the module.
The key is the name it's exported on and the value is the array of declarations for that name.
This will include declarations that are transitively exported from other modules. If you mean to get the export
declarations then use .getExportDeclarations().
Gets the export symbols.
Gets the file path's extension.
Gets the file path.
Get the first ancestor by syntax kind.
Syntax kind.
Gets the first ancestor by syntax kind or throws if not found.
Syntax kind.
Optionalmessage: string | (() => string)Gets the first child by syntax kind.
Syntax kind.
Gets the first child by syntax kind or throws an error if not found.
Syntax kind.
Optionalmessage: string | (() => string)Gets the first child if it matches the specified syntax kind.
Syntax kind.
Gets the first child if it matches the specified syntax kind or throws an error if not found.
Syntax kind.
Optionalmessage: string | (() => string)Gets the first descendant by syntax kind.
Syntax kind.
Gets the first descendant by syntax kind or throws.
Syntax kind.
Optionalmessage: string | (() => string)Gets the source file text position of the end of the last significant token or the start of the source file.
Gets the full text with leading trivia.
Gets the text length of the node with trivia.
Gets a function.
Name of the function.
Gets a function.
Function to use to find the function.
Gets a function or throws if it doesn't exist.
Name of the function.
Gets a function or throws if it doesn't exist.
Function to use to find the function.
Gets the direct function declaration children.
Gets the first import declaration that matches a condition, or undefined if it doesn't exist.
Condition to get the import declaration by.
Gets the first import declaration that matches a module specifier, or undefined if it doesn't exist.
Gets the first import declaration that matches a condition, or throws if it doesn't exist.
Condition to get the import declaration by.
Gets the first import declaration that matches a module specifier, or throws if it doesn't exist.
Get the module's import declarations.
Gets all the descendant string literals that reference a module.
Gets the indentation level of the current node.
Gets the indentation text.
Optionaloffset: numberOptional number of levels of indentation to add or remove.
Gets an interface.
Name of the interface.
Gets an interface.
Function to use to find the interface.
Gets an interface or throws if it doesn't exist.
Name of the interface.
Gets an interface or throws if it doesn't exist.
Function to use to find the interface.
Gets the direct interface declaration children.
Gets the syntax kind.
Gets the syntax kind name.
Gets the language variant of the source file.
Gets the script target of the source file.
Gets the last child by syntax kind.
Syntax kind.
Gets the last child by syntax kind or throws an error if not found.
Syntax kind.
Optionalmessage: string | (() => string)Gets the last child if it matches the specified syntax kind.
Syntax kind.
Gets the last child if it matches the specified syntax kind or throws an error if not found.
Syntax kind.
Optionalmessage: string | (() => string)Gets the last token of this node. Usually this is a close brace.
Gets the leading comment ranges of the current node.
Gets the node's leading trivia's text length.
Gets the character count from the start of the line to the provided position.
Position.
Gets any /// <reference lib="..." /> comments.
Gets the line and column number at the provided position (1-indexed).
Position in the source file.
Gets the string literals in this source file that references other source files.
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.
Name of the local symbol.
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.
Name of the local symbol.
Optionalmessage: string | (() => string)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.
Gets a module declaration child by name.
Name of the namespace.
Gets a module declaration child by condition.
Function to use to find the namespace.
Gets a module declaration child by name or throws if it doesn't exist.
Name of the namespace.
Gets a module declaration child by condition or throws if it doesn't exist.
Function to use to find the namespace.
Gets the module declaration children.
Gets the next sibling if it matches the specified kind.
Kind to check.
Gets the next sibiling if it matches the specified kind, or throws.
Kind to check.
Optionalmessage: string | (() => string)Gets a compiler node property wrapped in a Node.
Property name.
Gets the nodes that reference other source files in string literals.
Gets the first source file text position that is not whitespace taking into account comment nodes and a previous node's trailing trivia.
Gets the parent if it's a certain syntax kind.
Gets the parent if it's a certain syntax kind or throws.
Optionalmessage: string | (() => string)Gets the parent if it's a syntax list.
Gets the parent if it's a syntax list or throws an error otherwise.
Optionalmessage: string | (() => string)Goes up the parents (ancestors) of the node while a condition is true. Returns undefined if the initial parent doesn't match the condition.
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.
Syntax kind to check for.
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.
Syntax kind to check for.
Optionalmessage: string | (() => string)Goes up the parents (ancestors) of the node while a condition is true. Throws if the initial parent doesn't match the condition.
Goes up the parents (ancestors) of the node while a condition is true. Throws if the initial parent doesn't match the condition.
Gets any /// <reference path="..." /> comments.
Gets the source file text position where the node starts that includes the leading trivia (comments and whitespace).
Gets the pre-emit diagnostics of the specified source file.
Gets the previous sibling if it matches the specified kind.
Kind to check.
Gets the previous sibiling if it matches the specified kind, or throws.
Kind to check.
Optionalmessage: string | (() => string)Gets the project.
Gets the source files this source file references in string literals.
Gets the string literals in other source files that reference this source file.
Gets the import and exports in other source files that reference this source file.
Gets any source files that reference this source file.
Gets the relative path to the specified source file as a module specifier.
Source file.
Gets the relative path to the specified directory as a module specifier.
Directory.
Gets the relative path to the specified path.
The file or directory path.
Gets the relative path to another source file.
Source file.
Gets the relative path to another directory.
Directory.
Gets the script kind of the source file.
Gets the source file.
Gets the source file text position where the node starts that does not include the leading trivia (comments and whitespace).
OptionalincludeJsDocComments: booleanWhether to include the JS doc comments.
Gets the line number at the start of the node.
OptionalincludeJsDocComments: booleanWhether to include the JS doc comments or not.
Gets the position of the start of the line that this node starts on.
OptionalincludeJsDocComments: booleanWhether to include the JS doc comments or not.
Gets the first statement that matches the provided syntax kind or returns undefined if it doesn't exist.
Syntax kind to find the node by.
Gets the first statement that matches the provided syntax kind or throws if it doesn't exist.
Syntax kind to find the node by.
Gets the structure equivalent to this node.
Gets the compiler symbol or undefined if it doesn't exist.
Gets the symbol or throws an error if it doesn't exist.
Optionalmessage: string | (() => string)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.
Meaning of symbol to filter by.
Gets the text without leading trivia (comments and whitespace).
OptionalincludeJsDocComments: booleanWhether to include the js doc comments when getting the text.
Gets the text without leading trivia (comments and whitespace).
Options for getting the text.
Gets the trailing comment ranges of the current node.
Gets the text position of the next significant token or new line.
Gets the text length from the end of the current node to the next significant token or new line.
Gets the type of the node.
Gets a type alias.
Name of the type alias.
Gets a type alias.
Function to use to find the type alias.
Gets the direct type alias declaration children.
Gets a type alias or throws if it doesn't exist.
Name of the type alias.
Gets a type alias or throws if it doesn't exist.
Function to use to find the type alias.
Gets any /// <reference types="..." /> comments.
Gets a variable declaration.
Name of the variable declaration.
Gets a variable declaration.
Function to use to find the variable declaration.
Gets a variable declaration or throws if it doesn't exist.
Name of the variable declaration.
Gets a variable declaration or throws if it doesn't exist.
Function to use to find the variable declaration.
Gets all the variable declarations within the variable statement children.
Gets a variable statement.
Name of one of the variable statement's declarations.
Gets a variable statement.
Function to use to find the variable statement.
Gets a variable statement or throws if it doesn't exist.
Name of one of the variable statement's declarations.
Gets a variable statement or throws if it doesn't exist.
Function to use to find the variable statement.
Gets the direct variable statement children.
Gets the text length of the node without trivia.
OptionalincludeJsDocComments: booleanWhether to include the JS doc comments in the width or not.
Indents the line at the specified position.
Position.
Optionaltimes: numberTimes to indent. Specify a negative value to unindent.
Indents the lines within the specified range.
Position range.
Optionaltimes: numberTimes to indent. Specify a negative value to unindent.
Inserts an class declaration as a child.
Child index to insert at.
Structure of the class declaration to insert.
Inserts class declarations as a child.
Child index to insert at.
Structures of the class declarations to insert.
Inserts an enum declaration as a child.
Child index to insert at.
Structure of the enum declaration to insert.
Inserts enum declarations as a child.
Child index to insert at.
Structures of the enum declarations to insert.
Insert an export assignment.
Child index to insert at.
Structure that represents the export.
Insert export assignments into a file.
Child index to insert at.
Structures that represent the exports to insert.
Insert an export declaration.
Child index to insert at.
Structure that represents the export.
Insert export declarations.
Child index to insert at.
Structures that represent the exports to insert.
Inserts an function declaration as a child.
Child index to insert at.
Structure of the function declaration to insert.
Inserts function declarations as a child.
Child index to insert at.
Structures of the function declarations to insert.
Insert an import.
Child index to insert at.
Structure that represents the import.
Inserts imports.
Child index to insert at.
Structures that represent the imports to insert.
Inserts an interface declaration as a child.
Child index to insert at.
Structure of the interface declaration to insert.
Inserts interface declarations as a child.
Child index to insert at.
Structures of the interface declarations to insert.
Inserts a module declaration as a child.
Child index to insert at.
Structure of the namespace declaration to insert.
Inserts module declarations as children.
Child index to insert at.
Structures of the namespace declarations to insert.
Inserts statements at the specified index.
Child index to insert at.
Statements to insert.
The statements that were inserted.
Inserts text within the body of the node.
WARNING: This will forget any previously navigated descendant nodes.
Position to insert at.
Text to insert.
Inserts an type alias declaration as a child.
Child index to insert at.
Structure of the type alias declaration to insert.
Inserts type alias declarations as a child.
Child index to insert at.
Structures of the type alias declarations to insert.
Inserts a variable statement.
Structure of the variable statement.
Inserts variable statements.
Structures of the variable statements.
Gets if this is a declaration file.
Gets if this is the first node on the current line.
Gets if the source file was discovered while loading an external library.
Gets if the source file is a descendant of a node_modules directory.
Gets if the specified position is within a string.
Position.
Gets if this node is in a syntax list.
Returns if the node is the specified kind.
This is a type guard.
Syntax kind.
Gets if this source file has been saved or if the latest changes have been saved.
Moves this source file to a new file.
This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
New file path. Can be relative to the original file or an absolute path.
Optionaloptions: SourceFileMoveOptionsOptions for moving.
Moves this source file to a new file and asynchronously updates the file system immediately.
This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
New file path. Can be relative to the original file or an absolute path.
Optionaloptions: SourceFileMoveOptionsOptions for moving.
Moves this source file to a new file and synchronously updates the file system immediately.
This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
New file path. Can be relative to the original file or an absolute path.
Optionaloptions: SourceFileMoveOptionsOptions for moving.
Moves this source file to the specified directory.
This will modify the module specifiers in other files that specify this file and the module specifiers in the current file, if necessary.
Directory path or directory object to move the file to.
Optionaloptions: SourceFileMoveOptionsOptions for moving.
Subscribe to when the source file is modified.
Subscription.
Optionalsubscribe: booleanOptional and defaults to true. Use an explicit false to unsubscribe.
Organizes the imports in the file.
WARNING! This will forget all the nodes in the file! It's best to do this after you're all done with the file.
OptionalformatSettings: FormatCodeSettingsFormat code settings.
OptionaluserPreferences: UserPreferencesUser preferences for refactoring.
Prepends the specified whitespace to current node.
Text or writer function.
Prints the node using the compiler's printer.
Optionaloptions: PrintNodeOptionsOptions.
Refresh the source file from the file system.
WARNING: When updating from the file system, this will "forget" any previously navigated nodes.
What action ended up taking place.
Synchronously refreshes the source file from the file system.
WARNING: When updating from the file system, this will "forget" any previously navigated nodes.
What action ended up taking place.
Removes the statement at the specified index.
Child index to remove the statement at.
Removes the statements at the specified index range.
The start and end inclusive index range to remove.
Removes all the text within the node
Removes text within the body of the node.
WARNING: This will forget any previously navigated descendant nodes.
Start position to remove.
End position to remove.
Replaces text within the body of the node.
WARNING: This will forget any previously navigated descendant nodes.
Start and end position of the text to replace.
Text to replace the range with.
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.
Text or writer function to replace with.
The new node.
Asynchronously saves this file with any changes.
Synchronously saves this file with any changes.
Sets the node from a structure.
Structure to set the node with.
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.
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, []);
});
Deindents the line at the specified position.
Position.
Optionaltimes: numberTimes to unindent. Specify a negative value to indent.
Deindents the lines within the specified range.
Position range.
Optionaltimes: numberTimes to unindent. Specify a negative value to indent.
Gets if the compiler node was forgotten.
This will be true when the compiler node was forgotten or removed.
StatichasStatichasStatichasStatichasStaticisStaticisGets if the node is an AbstractableNode.
StaticisGets if the node is an AmbientableNode.
StaticisStaticisGets if the node is an ArrayTypeNode.
StaticisGets if the node is an AsyncableNode.
StaticisStaticisStaticisStaticisStaticisGets if the node is a CallSignatureDeclaration.
StaticisStaticisStaticisGets if the provided node is a CommentClassElement.
StaticisGets if the provided node is a CommentEnumMember.
StaticisGets if the provided node is a comment node.
StaticisGets if the provided node is a CommentObjectLiteralElement.
StaticisGets if the provided node is a CommentStatement.
StaticisGets if the provided value is a CommentTypeElement.
StaticisGets if the node is a ConditionalTypeNode.
StaticisGets if the node is a ConstructorDeclaration.
StaticisGets if the node is a ConstructorTypeNode.
StaticisGets if the node is a ConstructSignatureDeclaration.
StaticisGets if the node is a DecoratableNode.
StaticisStaticisStaticisGets if the node is an ExportableNode.
StaticisStaticisGets if the node is an Expression.
StaticisStaticisStaticisGets if the node is an ExtendsClauseableNode.
StaticisGets if the node is a FalseLiteral.
StaticisStaticisGets if the node is a FunctionTypeNode.
StaticisStaticisGets if the node is a GetAccessorDeclaration.
StaticisStaticisGets if the node is a ImplementsClauseableNode.
StaticisStaticisGets if the node is a ImportExpression.
StaticisGets if the node is a ImportTypeNode.
StaticisGets if the node is a IndexedAccessTypeNode.
StaticisGets if the node is a IndexSignatureDeclaration.
StaticisGets if the node is a InferTypeNode.
StaticisStaticisStaticisGets if the node is a IntersectionTypeNode.
StaticisGets if the node is a IterationStatement.
StaticisStaticisStaticisStaticisStaticisStaticisStaticisGets if the node is a JSDocUnknownTag.
StaticisGets if the node is a JsxAttributedNode.
StaticisStaticisGets if the node is a LeftHandSideExpression.
StaticisStaticisGets if the node is a LiteralExpression.
StaticisStaticisGets if the node is a LiteralTypeNode.
StaticisGets if the node is a MappedTypeNode.
StaticisGets if the node is a MemberExpression.
StaticisStaticisStaticisGets if the node is a ModuledNode.
StaticisStaticisStaticisStaticisStaticisGets if the node is a NodeWithTypeArguments.
StaticisGets if the node is a NullLiteral.
StaticisGets if the node is a OverloadableNode.
StaticisGets if the node is a OverrideableNode.
StaticisGets if the node is a ParameterDeclaration.
StaticisStaticisGets if the node is a ParenthesizedTypeNode.
StaticisGets if the node is a PrimaryExpression.
StaticisStaticisStaticisStaticisGets if the node is a ReadonlyableNode.
StaticisStaticisStaticisGets if the node is a RestTypeNode.
StaticisStaticisGets if the node is a ScopeableNode.
StaticisStaticisGets if the node is a SetAccessorDeclaration.
StaticisStaticisStaticisStaticisGets if the node is a StaticableNode.
StaticisGets if the node is a SuperExpression.
StaticisGets if the node is a TemplateLiteralTypeNode.
StaticisStaticisGets if the node is a ThisExpression.
StaticisGets if the node is a ThisTypeNode.
StaticisGets if the node is a TrueLiteral.
StaticisGets if the node is a TupleTypeNode.
StaticisStaticisGets if the node is a TypeAssertion.
StaticisStaticisGets if the node is a TypeElement.
StaticisStaticisGets if the node is a TypeLiteralNode.
StaticisStaticisGets if the node is a TypeOperatorTypeNode.
StaticisGets if the node is a TypeParameterDeclaration.
StaticisStaticisGets if the node is a TypePredicateNode.
StaticisGets if the node is a TypeQueryNode.
StaticisGets if the node is a TypeReferenceNode.
StaticisGets if the node is a UnaryExpression.
StaticisStaticisGets if the node is a UnionTypeNode.
StaticisStaticisGets if the node is a UpdateExpression.
Gets if the node is an AnyKeyword.