ts-simple-ast
Version:
TypeScript compiler wrapper for AST navigation and code generation.
1,390 lines (1,380 loc) • 1.08 MB
TypeScript
import CodeBlockWriter from "code-block-writer";
import {ts, SyntaxKind, CompilerOptions, EmitHint, ScriptKind, NewLineKind, LanguageVariant, ScriptTarget, TypeFlags, ObjectFlags, SymbolFlags, TypeFormatFlags, DiagnosticCategory} from "./typescript/ts";
/**
* Compiler wrapper.
*/
export declare class TsSimpleAst {
/**
* Initializes a new instance.
* @param options - Optional options.
* @param fileSystem - Optional file system host. Useful for mocking access to the file system.
*/
constructor(options?: Options, fileSystem?: FileSystemHost);
/** Gets the manipulation settings. */
readonly manipulationSettings: ManipulationSettingsContainer;
/**
* Adds an existing directory from the path or returns undefined if it doesn't exist.
*
* Will return the directory if it was already added.
* @param dirPath - Path to add the directory at.
*/
addDirectoryIfExists(dirPath: string): Directory | undefined;
/**
* Adds an existing directory from the path or throws if it doesn't exist.
*
* Will return the directory if it was already added.
* @param dirPath - Path to add the directory at.
* @throws DirectoryNotFoundError when the directory does not exist.
*/
addExistingDirectory(dirPath: string): Directory;
/**
* Creates a directory at the specified path.
* Note: Will not save the directory to disk until one of its source files is saved.
* @param dirPath - Path to create the directory at.
* @throws - InvalidOperationError if a directory already exists at the provided file path.
*/
createDirectory(dirPath: string): Directory;
/**
* Gets a directory by the specified path or throws it doesn't exist.
* @param dirPath - Path to create the directory at.
*/
getDirectoryOrThrow(dirPath: string): Directory;
/**
* Gets a directory by the specified path or returns undefined if it doesn't exist.
* @param dirPath - Directory path.
*/
getDirectory(dirPath: string): Directory | undefined;
/**
* Gets all the directories.
*/
getDirectories(): Directory[];
/**
* Gets the directories without a parent.
*/
getRootDirectories(): Directory[];
/**
* Add source files based on a file glob.
* @param fileGlobs - File glob to add files based on.
* @returns The matched source files.
*/
addExistingSourceFiles(fileGlob: string): SourceFile[];
/**
* Add source files based on file globs.
* @param fileGlobs - File globs to add files based on.
* @returns The matched source files.
*/
addExistingSourceFiles(fileGlobs: string[]): SourceFile[];
/**
* Adds a source file from a file path if it exists or returns undefined.
*
* Will return the source file if it was already added.
* @param filePath - File path to get the file from.
*/
addSourceFileIfExists(filePath: string): SourceFile | undefined;
/**
* Adds an existing source file from a file path or throws if it doesn't exist.
*
* Will return the source file if it was already added.
* @param filePath - File path to get the file from.
* @throws FileNotFoundError when the file is not found.
*/
addExistingSourceFile(filePath: string): SourceFile;
/**
* Adds all the source files from the specified tsconfig.json.
*
* Note that this is done by default when specifying a tsconfig file in the constructor and not explicitly setting the
* addFilesFromTsConfig option to false.
* @param tsConfigFilePath - File path to the tsconfig.json file.
*/
addSourceFilesFromTsConfig(tsConfigFilePath: string): SourceFile[];
/**
* Creates a source file at the specified file path.
*
* Note: The file will not be created and saved to the file system until .save() is called on the source file.
* @param filePath - File path of the source file.
* @throws - InvalidOperationError if a source file already exists at the provided file path.
*/
createSourceFile(filePath: string): SourceFile;
/**
* Creates a source file at the specified file path with the specified text.
*
* Note: The file will not be created and saved to the file system until .save() is called on the source file.
* @param filePath - File path of the source file.
* @param sourceFileText - Text of the source file.
* @throws - InvalidOperationError if a source file already exists at the provided file path.
*/
createSourceFile(filePath: string, sourceFileText: string): SourceFile;
/**
* Creates a source file at the specified file path with the specified text.
*
* Note: The file will not be created and saved to the file system until .save() is called on the source file.
* @param filePath - File path of the source file.
* @param structure - Structure that represents the source file.
* @throws - InvalidOperationError if a source file already exists at the provided file path.
*/
createSourceFile(filePath: string, structure: SourceFileStructure): SourceFile;
/**
* Removes a source file from the AST.
* @param sourceFile - Source file to remove.
* @returns True if removed.
*/
removeSourceFile(sourceFile: SourceFile): boolean;
/**
* Gets a source file by a file name or file path. Throws an error if it doesn't exist.
* @param fileNameOrPath - File name or path that the path could end with or equal.
*/
getSourceFileOrThrow(fileNameOrPath: string): SourceFile;
/**
* Gets a source file by a search function. Throws an erorr if it doesn't exist.
* @param searchFunction - Search function.
*/
getSourceFileOrThrow(searchFunction: (file: SourceFile) => boolean): SourceFile;
/**
* Gets a source file by a file name or file path. Returns undefined if none exists.
* @param fileNameOrPath - File name or path that the path could end with or equal.
*/
getSourceFile(fileNameOrPath: string): SourceFile | undefined;
/**
* Gets a source file by a search function. Returns undefined if none exists.
* @param searchFunction - Search function.
*/
getSourceFile(searchFunction: (file: SourceFile) => boolean): SourceFile | undefined;
/**
* Gets all the source files contained in the compiler wrapper.
* @param globPattern - Glob pattern for filtering out the source files.
*/
getSourceFiles(): SourceFile[];
/**
* Gets all the source files contained in the compiler wrapper that match a pattern.
* @param globPattern - Glob pattern for filtering out the source files.
*/
getSourceFiles(globPattern: string): SourceFile[];
/**
* Gets all the source files contained in the compiler wrapper that match the passed in patterns.
* @param globPatterns - Glob patterns for filtering out the source files.
*/
getSourceFiles(globPatterns: string[]): SourceFile[];
/**
* Saves all the unsaved source files.
*/
saveUnsavedSourceFiles(): Promise<void[]>;
/**
* Saves all the unsaved source files synchronously.
*
* Remarks: This might be very slow compared to the asynchronous version if there are a lot of files.
*/
saveUnsavedSourceFilesSync(): void;
/**
* Enables logging to the console.
* @param enabled - Enabled.
*/
enableLogging(enabled?: boolean): void;
private getUnsavedSourceFiles();
/**
* Gets the compiler diagnostics.
*/
getDiagnostics(): Diagnostic[];
/**
* Gets the pre-emit diagnostics.
*/
getPreEmitDiagnostics(): Diagnostic[];
/**
* Gets the language service.
*/
getLanguageService(): LanguageService;
/**
* Gets the program.
*/
getProgram(): Program;
/**
* Gets the type checker.
*/
getTypeChecker(): TypeChecker;
/**
* Gets the file system.
*/
getFileSystem(): FileSystemHost;
/**
* Emits all the source files.
* @param emitOptions - Optional emit options.
*/
emit(emitOptions?: EmitOptions): EmitResult;
/**
* Gets the compiler options.
*/
getCompilerOptions(): CompilerOptions;
/**
* Forgets the nodes created in the scope of the passed in block.
*
* This is an advanced method that can be used to easily "forget" all the nodes created within the scope of the block.
* @param block - Block of code to run.
*/
forgetNodesCreatedInBlock(block: (remember: (...node: Node[]) => void) => void): void;
/**
* Forgets the nodes created in the scope of the passed in block asynchronously.
*
* This is an advanced method that can be used to easily "forget" all the nodes created within the scope of the block.
* @param block - Block of code to run.
*/
forgetNodesCreatedInBlock(block: (remember: (...node: Node[]) => void) => Promise<void>): void;
}
export default TsSimpleAst;
export interface Options {
/** Compiler options */
compilerOptions?: CompilerOptions;
/** File path to the tsconfig.json file */
tsConfigFilePath?: string;
/** Whether to add the source files from the specified tsconfig.json or not. Defaults to true. */
addFilesFromTsConfig?: boolean;
/** Manipulation settings */
manipulationSettings?: Partial<ManipulationSettings>;
/** Whether to use a virtual file system. */
useVirtualFileSystem?: boolean;
}
export interface FileSystemHost {
delete(path: string): Promise<void>;
deleteSync(path: string): void;
readDirSync(dirPath: string): string[];
readFile(filePath: string, encoding?: string): Promise<string>;
readFileSync(filePath: string, encoding?: string): string;
writeFile(filePath: string, fileText: string): Promise<void>;
writeFileSync(filePath: string, fileText: string): void;
mkdir(dirPath: string): Promise<void>;
mkdirSync(dirPath: string): void;
fileExists(filePath: string): Promise<boolean>;
fileExistsSync(filePath: string): boolean;
directoryExists(dirPath: string): Promise<boolean>;
directoryExistsSync(dirPath: string): boolean;
getCurrentDirectory(): string;
glob(patterns: string[]): string[];
}
export declare class Directory {
private readonly _path;
private _global;
private readonly _pathParts;
private _parent;
private _directories;
private _sourceFiles;
/**
* Checks if this directory is an ancestor of the provided directory.
* @param possibleDescendant - Directory or source file that's a possible descendant.
*/
isAncestorOf(possibleDescendant: Directory | SourceFile): boolean;
/**
* Checks if this directory is a descendant of the provided directory.
* @param possibleAncestor - Directory or source file that's a possible ancestor.
*/
isDescendantOf(possibleAncestor: Directory): boolean;
/**
* Gets the path to the directory.
*/
getPath(): string;
/**
* Gets the directory path's base name.
*/
getBaseName(): string;
/**
* Gets the parent directory or throws if it doesn't exist or was never added to the AST.
*/
getParentOrThrow(): Directory;
/**
* Gets the parent directory if it exists and was added to the AST.
*/
getParent(): Directory | undefined;
/**
* Gets a child directory with the specified path or throws if not found.
* @param path - Relative path from this directory or absolute path.
*/
getDirectoryOrThrow(path: string): Directory;
/**
* Gets a child directory by the specified condition or throws if not found.
* @param condition - Condition to check the directory with.
*/
getDirectoryOrThrow(condition: (directory: Directory) => boolean): Directory;
/**
* Gets a directory with the specified path or undefined if not found.
* @param path - Relative path from this directory or absolute path.
*/
getDirectory(path: string): Directory | undefined;
/**
* Gets a child directory by the specified condition or undefined if not found.
* @param condition - Condition to check the directory with.
*/
getDirectory(condition: (directory: Directory) => boolean): Directory | undefined;
/**
* Gets a child source file with the specified path or throws if not found.
* @param path - Relative or absolute path to the file.
*/
getSourceFileOrThrow(path: string): SourceFile;
/**
* Gets a child source file by the specified condition or throws if not found.
* @param condition - Condition to check the source file with.
*/
getSourceFileOrThrow(condition: (sourceFile: SourceFile) => boolean): SourceFile;
/**
* Gets a child source file with the specified path or undefined if not found.
* @param path - Relative or absolute path to the file.
*/
getSourceFile(path: string): SourceFile | undefined;
/**
* Gets a child source file by the specified condition or undefined if not found.
* @param condition - Condition to check the source file with.
*/
getSourceFile(condition: (sourceFile: SourceFile) => boolean): SourceFile | undefined;
/**
* Gets the child directories.
*/
getDirectories(): Directory[];
/**
* Gets the source files within this directory.
*/
getSourceFiles(): SourceFile[];
/**
* Gets the source files in the current directory and all the descendant directories.
*/
getDescendantSourceFiles(): SourceFile[];
/**
* Gets the descendant directories.
*/
getDescendantDirectories(): Directory[];
/**
* Adds an existing directory to the AST from the relative path or directory name, or returns undefined if it doesn't exist.
*
* Will return the directory if it was already added.
* @param path - Directory name or path to the directory that should be added.
*/
addDirectoryIfExists(path: string): Directory | undefined;
/**
* Adds an existing directory to the AST from the relative path or directory name, or throws if it doesn't exist.
*
* Will return the directory if it was already added.
* @param path - Directory name or path to the directory that should be added.
* @throws DirectoryNotFoundError if the directory does not exist.
*/
addExistingDirectory(path: string): Directory;
/**
* Creates a directory if it doesn't exist.
* @param path - Relative or absolute path to the directory that should be created.
*/
createDirectory(path: string): Directory;
/**
* Creates a source file in the AST, relative to this directory.
*
* Note: The file will not be created and saved to the file system until .save() is called on the source file.
* @param relativeFilePath - Relative file path of the source file to create.
* @throws - InvalidOperationError if a source file already exists at the provided file name.
*/
createSourceFile(relativeFilePath: string): SourceFile;
/**
* Creates a source file in the AST, relative to this directory.
*
* Note: The file will not be created and saved to the file system until .save() is called on the source file.
* @param relativeFilePath - Relative file path of the source file to create.
* @param sourceFileText - Text of the source file.
* @throws - InvalidOperationError if a source file already exists at the provided file name.
*/
createSourceFile(relativeFilePath: string, sourceFileText: string): SourceFile;
/**
* Creates a source file in the AST, relative to this directory.
*
* Note: The file will not be created and saved to the file system until .save() is called on the source file.
* @param relativeFilePath - Relative file path of the source file to create.
* @param structure - Structure that represents the source file.
* @throws - InvalidOperationError if a source file already exists at the provided file name.
*/
createSourceFile(relativeFilePath: string, structure: SourceFileStructure): SourceFile;
/**
* Adds an existing source file to the AST, relative to this directory, or returns undefined.
*
* Will return the source file if it was already added.
* @param relativeFilePath - Relative file path to add.
*/
addSourceFileIfExists(relativeFilePath: string): SourceFile | undefined;
/**
* Adds an existing source file to the AST, relative to this directory, or throws if it doesn't exist.
*
* Will return the source file if it was already added.
* @param relativeFilePath - Relative file path to add.
* @throws FileNotFoundError when the file doesn't exist.
*/
addExistingSourceFile(relativeFilePath: string): SourceFile;
/**
* Emits the files in the directory.
* @param options - Options for emitting.
*/
emit(options?: {
emitOnlyDtsFiles?: boolean;
outDir?: string;
declarationDir?: string;
}): Promise<DirectoryEmitResult>;
/**
* Emits the files in the directory synchronously.
*
* Remarks: This might be very slow compared to the asynchronous version if there are a lot of files.
* @param options - Options for emitting.
*/
emitSync(options?: {
emitOnlyDtsFiles?: boolean;
outDir?: string;
declarationDir?: string;
}): DirectoryEmitResult;
private _emitInternal(options?);
/**
* Copies a directory to a new directory.
* @param relativeOrAbsolutePath - The relative or absolute path to the new directory.
* @param options - Options.
* @returns The directory the copy was made to.
*/
copy(relativeOrAbsolutePath: string, options?: {
overwrite?: boolean;
}): Directory;
/**
* Asyncronously deletes the directory and all its descendants.
*
* WARNING: This will delete the directory from the file system.
*/
delete(): Promise<void>;
/**
* Synchronously deletes the directory and all its descendants.
*
* WARNING: This will delete the directory from the file system.
*/
deleteSync(): void;
/**
* Removes the directory and all its descendants from the AST.
*
* Note: Does not delete the directory from the file system.
*/
remove(): void;
/**
* Saves all the unsaved descendant source files.
*/
saveUnsavedSourceFiles(): Promise<void[]>;
/**
* Saves all the unsaved descendant source files synchronously.
*
* Remarks: This might be very slow compared to the asynchronous version if there are a lot of files.
*/
saveUnsavedSourceFilesSync(): void;
private throwIfDeletedOrRemoved();
private _getUnsavedSourceFiles();
}
export declare class DirectoryEmitResult {
private readonly _emitSkipped;
private readonly _outputFilePaths;
/**
* Gets if the emit was skipped.
*/
getEmitSkipped(): boolean;
/**
* Gets the output file paths.
*/
getOutputFilePaths(): string[];
}
/**
* Creates a wrapped node from a compiler node.
* @param node - Node to create a wrapped node from.
* @param info - Info for creating the wrapped node.
*/
export declare function createWrappedNode<T extends ts.Node = ts.Node>(node: T, opts?: CreateWrappedNodeOptions): Node<T>;
export interface CreateWrappedNodeOptions {
/**
* Compiler options.
*/
compilerOptions?: CompilerOptions;
/**
* Optional source file of the node. Will make it not bother going up the tree to find the source file.
*/
sourceFile?: ts.SourceFile;
/**
* Type checker.
*/
typeChecker?: ts.TypeChecker;
}
/**
* Gets the compiler options from a specified tsconfig.json
* @param filePath - File path to the tsconfig.json.
* @param fileSystemHost - Optional file system host.
*/
export declare function getCompilerOptionsFromTsConfig(filePath: string, fileSystemHost?: FileSystemHost): {
options: CompilerOptions;
errors: Diagnostic[];
};
/**
* Prints the provided node using the compiler's printer.
* @param node - Compiler node.
* @param options - Options.
*/
export declare function printNode(node: ts.Node, options?: PrintNodeOptions): string;
/**
* Prints the provided node using the compiler's printer.
* @param node - Compiler node.
* @param sourceFile - Compiler source file.
* @param options - Options.
*/
export declare function printNode(node: ts.Node, sourceFile: ts.SourceFile, options?: PrintNodeOptions): string;
/**
* Options for printing a node.
*/
export interface PrintNodeOptions {
/**
* Whether to remove comments or not.
*/
removeComments?: boolean;
/**
* New line kind.
*
* Defaults to line feed.
*/
newLineKind?: NewLineKind;
/**
* From the compiler api: "A value indicating the purpose of a node. This is primarily used to
* distinguish between an `Identifier` used in an expression position, versus an
* `Identifier` used as an `IdentifierName` as part of a declaration. For most nodes you
* should just pass `Unspecified`."
*
* Defaults to `Unspecified`.
*/
emitHint?: EmitHint;
/**
* The script kind.
*
* Defaults to TSX. This is only useful when not using a wrapped node and not providing a source file.
*/
scriptKind?: ScriptKind;
}
export declare type Constructor<T> = new (...args: any[]) => T;
/**
* Type guards for checking the type of a node.
*/
export declare class TypeGuards {
private constructor();
/**
* Gets if the node has an expression.
* @param node - Node to check.
*/
static hasExpression(node: Node): node is Node & {
getExpression(): Expression;
};
/**
* Gets if the node has a name.
* @param node - Node to check.
*/
static hasName(node: Node): node is Node & {
getName(): string;
};
/**
* Gets if the node is an AbstractableNode.
* @param node - Node to check.
*/
static isAbstractableNode(node: Node): node is AbstractableNode & Node;
/**
* Gets if the node is an AmbientableNode.
* @param node - Node to check.
*/
static isAmbientableNode(node: Node): node is AmbientableNode & Node;
/**
* Gets if the node is an ArgumentedNode.
* @param node - Node to check.
*/
static isArgumentedNode(node: Node): node is ArgumentedNode & Node;
/**
* Gets if the node is an ArrayLiteralExpression.
* @param node - Node to check.
*/
static isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression;
/**
* Gets if the node is an ArrayTypeNode.
* @param node - Node to check.
*/
static isArrayTypeNode(node: Node): node is ArrayTypeNode;
/**
* Gets if the node is an ArrowFunction.
* @param node - Node to check.
*/
static isArrowFunction(node: Node): node is ArrowFunction;
/**
* Gets if the node is an AsExpression.
* @param node - Node to check.
*/
static isAsExpression(node: Node): node is AsExpression;
/**
* Gets if the node is an AsyncableNode.
* @param node - Node to check.
*/
static isAsyncableNode(node: Node): node is AsyncableNode & Node;
/**
* Gets if the node is an AwaitExpression.
* @param node - Node to check.
*/
static isAwaitExpression(node: Node): node is AwaitExpression;
/**
* Gets if the node is an AwaitableNode.
* @param node - Node to check.
*/
static isAwaitableNode(node: Node): node is AwaitableNode & Node;
/**
* Gets if the node is a BinaryExpression.
* @param node - Node to check.
*/
static isBinaryExpression(node: Node): node is BinaryExpression;
/**
* Gets if the node is a BindingNamedNode.
* @param node - Node to check.
*/
static isBindingNamedNode(node: Node): node is BindingNamedNode & Node;
/**
* Gets if the node is a Block.
* @param node - Node to check.
*/
static isBlock(node: Node): node is Block;
/**
* Gets if the node is a BodiedNode.
* @param node - Node to check.
*/
static isBodiedNode(node: Node): node is BodiedNode & Node;
/**
* Gets if the node is a BodyableNode.
* @param node - Node to check.
*/
static isBodyableNode(node: Node): node is BodyableNode & Node;
/**
* Gets if the node is a BooleanLiteral.
* @param node - Node to check.
*/
static isBooleanLiteral(node: Node): node is BooleanLiteral;
/**
* Gets if the node is a BreakStatement.
* @param node - Node to check.
*/
static isBreakStatement(node: Node): node is BreakStatement;
/**
* Gets if the node is a CallExpression.
* @param node - Node to check.
*/
static isCallExpression(node: Node): node is CallExpression;
/**
* Gets if the node is a CallSignatureDeclaration.
* @param node - Node to check.
*/
static isCallSignatureDeclaration(node: Node): node is CallSignatureDeclaration;
/**
* Gets if the node is a CaseBlock.
* @param node - Node to check.
*/
static isCaseBlock(node: Node): node is CaseBlock;
/**
* Gets if the node is a CaseClause.
* @param node - Node to check.
*/
static isCaseClause(node: Node): node is CaseClause;
/**
* Gets if the node is a CatchClause.
* @param node - Node to check.
*/
static isCatchClause(node: Node): node is CatchClause;
/**
* Gets if the node is a ChildOrderableNode.
* @param node - Node to check.
*/
static isChildOrderableNode(node: Node): node is ChildOrderableNode & Node;
/**
* Gets if the node is a ClassDeclaration.
* @param node - Node to check.
*/
static isClassDeclaration(node: Node): node is ClassDeclaration;
/**
* Gets if the node is a CommaListExpression.
* @param node - Node to check.
*/
static isCommaListExpression(node: Node): node is CommaListExpression;
/**
* Gets if the node is a ComputedPropertyName.
* @param node - Node to check.
*/
static isComputedPropertyName(node: Node): node is ComputedPropertyName;
/**
* Gets if the node is a ConditionalExpression.
* @param node - Node to check.
*/
static isConditionalExpression(node: Node): node is ConditionalExpression;
/**
* Gets if the node is a ConstructSignatureDeclaration.
* @param node - Node to check.
*/
static isConstructSignatureDeclaration(node: Node): node is ConstructSignatureDeclaration;
/**
* Gets if the node is a ConstructorDeclaration.
* @param node - Node to check.
*/
static isConstructorDeclaration(node: Node): node is ConstructorDeclaration;
/**
* Gets if the node is a ConstructorTypeNode.
* @param node - Node to check.
*/
static isConstructorTypeNode(node: Node): node is ConstructorTypeNode;
/**
* Gets if the node is a ContinueStatement.
* @param node - Node to check.
*/
static isContinueStatement(node: Node): node is ContinueStatement;
/**
* Gets if the node is a DebuggerStatement.
* @param node - Node to check.
*/
static isDebuggerStatement(node: Node): node is DebuggerStatement;
/**
* Gets if the node is a DeclarationNamedNode.
* @param node - Node to check.
*/
static isDeclarationNamedNode(node: Node): node is DeclarationNamedNode & Node;
/**
* Gets if the node is a DecoratableNode.
* @param node - Node to check.
*/
static isDecoratableNode(node: Node): node is DecoratableNode & Node;
/**
* Gets if the node is a Decorator.
* @param node - Node to check.
*/
static isDecorator(node: Node): node is Decorator;
/**
* Gets if the node is a DefaultClause.
* @param node - Node to check.
*/
static isDefaultClause(node: Node): node is DefaultClause;
/**
* Gets if the node is a DeleteExpression.
* @param node - Node to check.
*/
static isDeleteExpression(node: Node): node is DeleteExpression;
/**
* Gets if the node is a DoStatement.
* @param node - Node to check.
*/
static isDoStatement(node: Node): node is DoStatement;
/**
* Gets if the node is an ElementAccessExpression.
* @param node - Node to check.
*/
static isElementAccessExpression(node: Node): node is ElementAccessExpression;
/**
* Gets if the node is an EmptyStatement.
* @param node - Node to check.
*/
static isEmptyStatement(node: Node): node is EmptyStatement;
/**
* Gets if the node is an EnumDeclaration.
* @param node - Node to check.
*/
static isEnumDeclaration(node: Node): node is EnumDeclaration;
/**
* Gets if the node is an EnumMember.
* @param node - Node to check.
*/
static isEnumMember(node: Node): node is EnumMember;
/**
* Gets if the node is an ExportAssignment.
* @param node - Node to check.
*/
static isExportAssignment(node: Node): node is ExportAssignment;
/**
* Gets if the node is an ExportDeclaration.
* @param node - Node to check.
*/
static isExportDeclaration(node: Node): node is ExportDeclaration;
/**
* Gets if the node is an ExportSpecifier.
* @param node - Node to check.
*/
static isExportSpecifier(node: Node): node is ExportSpecifier;
/**
* Gets if the node is an ExportableNode.
* @param node - Node to check.
*/
static isExportableNode(node: Node): node is ExportableNode & Node;
/**
* Gets if the node is an Expression.
* @param node - Node to check.
*/
static isExpression(node: Node): node is Expression;
/**
* Gets if the node is an ExpressionStatement.
* @param node - Node to check.
*/
static isExpressionStatement(node: Node): node is ExpressionStatement;
/**
* Gets if the node is an ExpressionWithTypeArguments.
* @param node - Node to check.
*/
static isExpressionWithTypeArguments(node: Node): node is ExpressionWithTypeArguments;
/**
* Gets if the node is an ExpressionedNode.
* @param node - Node to check.
*/
static isExpressionedNode(node: Node): node is ExpressionedNode & Node;
/**
* Gets if the node is an ExtendsClauseableNode.
* @param node - Node to check.
*/
static isExtendsClauseableNode(node: Node): node is ExtendsClauseableNode & Node;
/**
* Gets if the node is an ExternalModuleReference.
* @param node - Node to check.
*/
static isExternalModuleReference(node: Node): node is ExternalModuleReference;
/**
* Gets if the node is a ForInStatement.
* @param node - Node to check.
*/
static isForInStatement(node: Node): node is ForInStatement;
/**
* Gets if the node is a ForOfStatement.
* @param node - Node to check.
*/
static isForOfStatement(node: Node): node is ForOfStatement;
/**
* Gets if the node is a ForStatement.
* @param node - Node to check.
*/
static isForStatement(node: Node): node is ForStatement;
/**
* Gets if the node is a FunctionDeclaration.
* @param node - Node to check.
*/
static isFunctionDeclaration(node: Node): node is FunctionDeclaration;
/**
* Gets if the node is a FunctionExpression.
* @param node - Node to check.
*/
static isFunctionExpression(node: Node): node is FunctionExpression;
/**
* Gets if the node is a FunctionLikeDeclaration.
* @param node - Node to check.
*/
static isFunctionLikeDeclaration(node: Node): node is FunctionLikeDeclaration & Node;
/**
* Gets if the node is a FunctionTypeNode.
* @param node - Node to check.
*/
static isFunctionTypeNode(node: Node): node is FunctionTypeNode;
/**
* Gets if the node is a GeneratorableNode.
* @param node - Node to check.
*/
static isGeneratorableNode(node: Node): node is GeneratorableNode & Node;
/**
* Gets if the node is a GetAccessorDeclaration.
* @param node - Node to check.
*/
static isGetAccessorDeclaration(node: Node): node is GetAccessorDeclaration;
/**
* Gets if the node is a HeritageClause.
* @param node - Node to check.
*/
static isHeritageClause(node: Node): node is HeritageClause;
/**
* Gets if the node is a HeritageClauseableNode.
* @param node - Node to check.
*/
static isHeritageClauseableNode(node: Node): node is HeritageClauseableNode & Node;
/**
* Gets if the node is a Identifier.
* @param node - Node to check.
*/
static isIdentifier(node: Node): node is Identifier;
/**
* Gets if the node is a IfStatement.
* @param node - Node to check.
*/
static isIfStatement(node: Node): node is IfStatement;
/**
* Gets if the node is a ImplementsClauseableNode.
* @param node - Node to check.
*/
static isImplementsClauseableNode(node: Node): node is ImplementsClauseableNode & Node;
/**
* Gets if the node is a ImportDeclaration.
* @param node - Node to check.
*/
static isImportDeclaration(node: Node): node is ImportDeclaration;
/**
* Gets if the node is a ImportEqualsDeclaration.
* @param node - Node to check.
*/
static isImportEqualsDeclaration(node: Node): node is ImportEqualsDeclaration;
/**
* Gets if the node is a ImportExpression.
* @param node - Node to check.
*/
static isImportExpression(node: Node): node is ImportExpression;
/**
* Gets if the node is a ImportSpecifier.
* @param node - Node to check.
*/
static isImportSpecifier(node: Node): node is ImportSpecifier;
/**
* Gets if the node is a IndexSignatureDeclaration.
* @param node - Node to check.
*/
static isIndexSignatureDeclaration(node: Node): node is IndexSignatureDeclaration;
/**
* Gets if the node is a InitializerExpressionableNode.
* @param node - Node to check.
*/
static isInitializerExpressionableNode(node: Node): node is InitializerExpressionableNode & Node;
/**
* Gets if the node is a InitializerGetExpressionableNode.
* @param node - Node to check.
*/
static isInitializerGetExpressionableNode(node: Node): node is InitializerGetExpressionableNode & Node;
/**
* Gets if the node is a InitializerSetExpressionableNode.
* @param node - Node to check.
*/
static isInitializerSetExpressionableNode(node: Node): node is InitializerSetExpressionableNode & Node;
/**
* Gets if the node is a InterfaceDeclaration.
* @param node - Node to check.
*/
static isInterfaceDeclaration(node: Node): node is InterfaceDeclaration;
/**
* Gets if the node is a IntersectionTypeNode.
* @param node - Node to check.
*/
static isIntersectionTypeNode(node: Node): node is IntersectionTypeNode;
/**
* Gets if the node is a IterationStatement.
* @param node - Node to check.
*/
static isIterationStatement(node: Node): node is IterationStatement;
/**
* Gets if the node is a JSDoc.
* @param node - Node to check.
*/
static isJSDoc(node: Node): node is JSDoc;
/**
* Gets if the node is a JSDocAugmentsTag.
* @param node - Node to check.
*/
static isJSDocAugmentsTag(node: Node): node is JSDocAugmentsTag;
/**
* Gets if the node is a JSDocClassTag.
* @param node - Node to check.
*/
static isJSDocClassTag(node: Node): node is JSDocClassTag;
/**
* Gets if the node is a JSDocParameterTag.
* @param node - Node to check.
*/
static isJSDocParameterTag(node: Node): node is JSDocParameterTag;
/**
* Gets if the node is a JSDocPropertyLikeTag.
* @param node - Node to check.
*/
static isJSDocPropertyLikeTag(node: Node): node is JSDocPropertyLikeTag & Node;
/**
* Gets if the node is a JSDocPropertyTag.
* @param node - Node to check.
*/
static isJSDocPropertyTag(node: Node): node is JSDocPropertyTag;
/**
* Gets if the node is a JSDocReturnTag.
* @param node - Node to check.
*/
static isJSDocReturnTag(node: Node): node is JSDocReturnTag;
/**
* Gets if the node is a JSDocTag.
* @param node - Node to check.
*/
static isJSDocTag(node: Node): node is JSDocTag;
/**
* Gets if the node is a JSDocTypeTag.
* @param node - Node to check.
*/
static isJSDocTypeTag(node: Node): node is JSDocTypeTag;
/**
* Gets if the node is a JSDocTypedefTag.
* @param node - Node to check.
*/
static isJSDocTypedefTag(node: Node): node is JSDocTypedefTag;
/**
* Gets if the node is a JSDocUnknownTag.
* @param node - Node to check.
*/
static isJSDocUnknownTag(node: Node): node is JSDocUnknownTag;
/**
* Gets if the node is a JSDocableNode.
* @param node - Node to check.
*/
static isJSDocableNode(node: Node): node is JSDocableNode & Node;
/**
* Gets if the node is a JsxAttribute.
* @param node - Node to check.
*/
static isJsxAttribute(node: Node): node is JsxAttribute;
/**
* Gets if the node is a JsxClosingElement.
* @param node - Node to check.
*/
static isJsxClosingElement(node: Node): node is JsxClosingElement;
/**
* Gets if the node is a JsxClosingFragment.
* @param node - Node to check.
*/
static isJsxClosingFragment(node: Node): node is JsxClosingFragment;
/**
* Gets if the node is a JsxElement.
* @param node - Node to check.
*/
static isJsxElement(node: Node): node is JsxElement;
/**
* Gets if the node is a JsxExpression.
* @param node - Node to check.
*/
static isJsxExpression(node: Node): node is JsxExpression;
/**
* Gets if the node is a JsxFragment.
* @param node - Node to check.
*/
static isJsxFragment(node: Node): node is JsxFragment;
/**
* Gets if the node is a JsxOpeningElement.
* @param node - Node to check.
*/
static isJsxOpeningElement(node: Node): node is JsxOpeningElement;
/**
* Gets if the node is a JsxOpeningFragment.
* @param node - Node to check.
*/
static isJsxOpeningFragment(node: Node): node is JsxOpeningFragment;
/**
* Gets if the node is a JsxSelfClosingElement.
* @param node - Node to check.
*/
static isJsxSelfClosingElement(node: Node): node is JsxSelfClosingElement;
/**
* Gets if the node is a JsxSpreadAttribute.
* @param node - Node to check.
*/
static isJsxSpreadAttribute(node: Node): node is JsxSpreadAttribute;
/**
* Gets if the node is a JsxText.
* @param node - Node to check.
*/
static isJsxText(node: Node): node is JsxText;
/**
* Gets if the node is a LabeledStatement.
* @param node - Node to check.
*/
static isLabeledStatement(node: Node): node is LabeledStatement;
/**
* Gets if the node is a LeftHandSideExpression.
* @param node - Node to check.
*/
static isLeftHandSideExpression(node: Node): node is LeftHandSideExpression;
/**
* Gets if the node is a LeftHandSideExpressionedNode.
* @param node - Node to check.
*/
static isLeftHandSideExpressionedNode(node: Node): node is LeftHandSideExpressionedNode & Node;
/**
* Gets if the node is a LiteralExpression.
* @param node - Node to check.
*/
static isLiteralExpression(node: Node): node is LiteralExpression;
/**
* Gets if the node is a LiteralLikeNode.
* @param node - Node to check.
*/
static isLiteralLikeNode(node: Node): node is LiteralLikeNode & Node;
/**
* Gets if the node is a LiteralTypeNode.
* @param node - Node to check.
*/
static isLiteralTypeNode(node: Node): node is LiteralTypeNode;
/**
* Gets if the node is a MemberExpression.
* @param node - Node to check.
*/
static isMemberExpression(node: Node): node is MemberExpression;
/**
* Gets if the node is a MetaProperty.
* @param node - Node to check.
*/
static isMetaProperty(node: Node): node is MetaProperty;
/**
* Gets if the node is a MethodDeclaration.
* @param node - Node to check.
*/
static isMethodDeclaration(node: Node): node is MethodDeclaration;
/**
* Gets if the node is a MethodSignature.
* @param node - Node to check.
*/
static isMethodSignature(node: Node): node is MethodSignature;
/**
* Gets if the node is a ModifierableNode.
* @param node - Node to check.
*/
static isModifierableNode(node: Node): node is ModifierableNode & Node;
/**
* Gets if the node is a NameableNode.
* @param node - Node to check.
*/
static isNameableNode(node: Node): node is NameableNode & Node;
/**
* Gets if the node is a NamedNode.
* @param node - Node to check.
*/
static isNamedNode(node: Node): node is NamedNode & Node;
/**
* Gets if the node is a NamespaceChildableNode.
* @param node - Node to check.
*/
static isNamespaceChildableNode(node: Node): node is NamespaceChildableNode & Node;
/**
* Gets if the node is a NamespaceDeclaration.
* @param node - Node to check.
*/
static isNamespaceDeclaration(node: Node): node is NamespaceDeclaration;
/**
* Gets if the node is a NewExpression.
* @param node - Node to check.
*/
static isNewExpression(node: Node): node is NewExpression;
/**
* Gets if the node is a NoSubstitutionTemplateLiteral.
* @param node - Node to check.
*/
static isNoSubstitutionTemplateLiteral(node: Node): node is NoSubstitutionTemplateLiteral;
/**
* Gets if the node is a NonNullExpression.
* @param node - Node to check.
*/
static isNonNullExpression(node: Node): node is NonNullExpression;
/**
* Gets if the node is a NotEmittedStatement.
* @param node - Node to check.
*/
static isNotEmittedStatement(node: Node): node is NotEmittedStatement;
/**
* Gets if the node is a NullLiteral.
* @param node - Node to check.
*/
static isNullLiteral(node: Node): node is NullLiteral;
/**
* Gets if the node is a NumericLiteral.
* @param node - Node to check.
*/
static isNumericLiteral(node: Node): node is NumericLiteral;
/**
* Gets if the node is a ObjectLiteralExpression.
* @param node - Node to check.
*/
static isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression;
/**
* Gets if the node is a OmittedExpression.
* @param node - Node to check.
*/
static isOmittedExpression(node: Node): node is OmittedExpression;
/**
* Gets if the node is a OverloadableNode.
* @param node - Node to check.
*/
static isOverloadableNode(node: Node): node is OverloadableNode & Node;
/**
* Gets if the node is a ParameterDeclaration.
* @param node - Node to check.
*/
static isParameterDeclaration(node: Node): node is ParameterDeclaration;
/**
* Gets if the node is a ParameteredNode.
* @param node - Node to check.
*/
static isParameteredNode(node: Node): node is ParameteredNode & Node;
/**
* Gets if the node is a ParenthesizedExpression.
* @param node - Node to check.
*/
static isParenthesizedExpression(node: Node): node is ParenthesizedExpression;
/**
* Gets if the node is a PartiallyEmittedExpression.
* @param node - Node to check.
*/
static isPartiallyEmittedExpression(node: Node): node is PartiallyEmittedExpression;
/**
* Gets if the node is a PostfixUnaryExpression.
* @param node - Node to check.
*/
static isPostfixUnaryExpression(node: Node): node is PostfixUnaryExpression;
/**
* Gets if the node is a PrefixUnaryExpression.
* @param node - Node to check.
*/
static isPrefixUnaryExpression(node: Node): node is PrefixUnaryExpression;
/**
* Gets if the node is a PrimaryExpression.
* @param node - Node to check.
*/
static isPrimaryExpression(node: Node): node is PrimaryExpression;
/**
* Gets if the node is a PropertyAccessExpression.
* @param node - Node to check.
*/
static isPropertyAccessExpression(node: Node): node is PropertyAccessExpression;
/**
* Gets if the node is a PropertyAssignment.
* @param node - Node to check.
*/
static isPropertyAssignment(node: Node): node is PropertyAssignment;
/**
* Gets if the node is a PropertyDeclaration.
* @param node - Node to check.
*/
static isPropertyDeclaration(node: Node): node is PropertyDeclaration;
/**
* Gets if the node is a PropertyNamedNode.
* @param node - Node to check.
*/
static isPropertyNamedNode(node: Node): node is PropertyNamedNode & Node;
/**
* Gets if the node is a PropertySignature.
* @param node - Node to check.
*/
static isPropertySignature(node: Node): node is PropertySignature;
/**
* Gets if the node is a QualifiedName.
* @param node - Node to check.
*/
static isQualifiedName(node: Node): node is QualifiedName;
/**
* Gets if the node is a QuestionTokenableNode.
* @param node - Node to check.
*/
static isQuestionTokenableNode(node: Node): node is QuestionTokenableNode & Node;
/**
* Gets if the node is a ReadonlyableNode.
* @param node - Node to check.
*/
static isReadonlyableNode(node: Node): node is ReadonlyableNode & Node;
/**
* Gets if the node is a RegularExpressionLiteral.
* @param node - Node to check.
*/
static isRegularExpressionLiteral(node: Node): node is RegularExpressionLiteral;
/**
* Gets if the node is a ReturnStatement.
* @param node - Node to check.
*/
static isReturnStatement(node: Node): node is ReturnStatement;
/**
* Gets if the node is a ReturnTypedNode.
* @param node - Node to check.
*/
static isReturnTypedNode(node: Node): node is ReturnTypedNode & Node;
/**
* Gets if the node is a ScopeableNode.
* @param node - Node to check.
*/
static isScopeableNode(node: Node): node is ScopeableNode & Node;
/**
* Gets if the node is a ScopedNode.
* @param node - Node to check.
*/
static isScopedNode(node: Node): node is ScopedNode & Node;
/**
* Gets if the node is a SemicolonToken.
* @param node - Node to check.
*/
static isSemicolonToken(node: Node): node is Node;
/**
* Gets if the node is a SetAccessorDeclaration.
* @param node - Node to check.
*/
static isSetAccessorDeclaration(node: Node): node is SetAccessorDeclaration;
/**
* Gets if the node is a ShorthandPropertyAssignment.
* @param node - Node to check.
*/
static isShorthandPropertyAssignment(node: Node): node is ShorthandPropertyAssignment;
/**
* Gets if the node is a SignaturedDeclaration.
* @param node - Node to check.
*/
static isSignaturedDeclaration(node: Node): node is SignaturedDeclaration & Node;
/**
* Gets if the node is a SourceFile.
* @param node - Node to check.
*/
static isSourceFile(node: Node): node is SourceFile;
/**
* Gets if the node is a SpreadAssignment.
* @param node - Node to check.
*/
static isSpreadAssignment(node: Node): node is SpreadAssignment;
/**
* Gets if the node is a SpreadElement.
* @param node - Node to check.
*/
static isSpreadElement(node: Node): node is SpreadElement;
/**
* Gets if the node is a Statement.
* @param node - Node to check.
*/
static isStatement(node: Node): node is Statement;
/**
* Gets if the node is a StatementedNode.
* @param node - Node to check.
*/
static isStatementedNode(node: Node): node is StatementedNode & Node;
/**
* Gets if the node is a StaticableNode.
* @param node - Node to check.
*/
static isStaticableNode(node: Node): node is StaticableNode & Node;
/**
* Gets if the node is a StringLiteral.
* @param node - Node to check.
*/
static isStringLiteral(node: Node): node is StringLiteral;
/**
* Gets if the node is a SuperExpression.
* @param node - Node to check.
*/
static isSuperExpression(node: Node): node is SuperExpression;
/**
* Gets if the node is a SwitchStatement.
* @param node - Node to check.
*/
static isSwitchStatement(node: Node): node is SwitchStatement;
/**
* Gets if the node is a SyntaxList.
* @param node - Node to check.
*/
static isSyntaxList(node: Node): node is SyntaxList;
/**
* Gets if the node is a TaggedTemplateExpression.
* @param node - Node to check.
*/
static isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression;
/**
* Gets if the node is a TemplateExpression.
* @param node - Node to check.
*/
static isTemplateExpression(node: Node): node is TemplateExpression;
/**
* Gets if the node is a TemplateHead.
* @param node - Node to check.
*/
static isTemplateHead(node: Node): node is TemplateHead;
/**
* Gets if the node is a TemplateMiddle.
* @param node - Node to check.
*/
static isTemplateMiddle(node: Node): node is TemplateMiddle;
/**
* Gets if the node is a TemplateSpan.
* @param node - Node to check.
*/
stati