UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for static analysis and code manipulation.

1,310 lines (1,290 loc) 350 kB
import { ts, SyntaxKind, CompilerOptions, EmitHint, ScriptKind, NewLineKind, LanguageVariant, ScriptTarget, TypeFlags, ObjectFlags, SymbolFlags, TypeFormatFlags, DiagnosticCategory, EditorSettings, ModuleResolutionKind, CompilerApiNodeBrandPropertyNamesType } from "./typescript/typescript"; import { CodeBlockWriter } from "./codeBlockWriter/code-block-writer"; export declare class Directory { private _global; private _path; private _pathParts; /** * 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 dirPath - Directory name or path to the directory that should be added. * @param options - Options. */ addExistingDirectoryIfExists(dirPath: string, options?: DirectoryAddOptions): 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 dirPath - Directory name or path to the directory that should be added. * @throws DirectoryNotFoundError if the directory does not exist. */ addExistingDirectory(dirPath: string, options?: DirectoryAddOptions): Directory; /** * Creates a directory if it doesn't exist. * @param dirPath - Relative or absolute path to the directory that should be created. */ createDirectory(dirPath: 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. * @param options - Options. * @throws - InvalidOperationError if a source file already exists at the provided file name. */ createSourceFile(relativeFilePath: string, sourceFileText: string, options?: SourceFileCreateOptions): 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. * @param options - Options. * @throws - InvalidOperationError if a source file already exists at the provided file name. */ createSourceFile(relativeFilePath: string, structure: SourceFileStructure, options?: SourceFileCreateOptions): 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. * @param options - Options for adding the source file. */ addExistingSourceFileIfExists(relativeFilePath: string, options?: SourceFileAddOptions): 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. * @param options - Options for adding the source file. * @throws FileNotFoundError when the file doesn't exist. */ addExistingSourceFile(relativeFilePath: string, options?: SourceFileAddOptions): 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; /** * 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?: DirectoryCopyOptions): Directory; /** * Immediately copies the directory to the specified path asynchronously. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path. * @param options - Options for moving the directory. * @remarks If includeTrackedFiles is true, then it will execute the pending operations in the current directory. */ copyImmediately(relativeOrAbsolutePath: string, options?: DirectoryCopyOptions): Promise<Directory>; /** * Immediately copies the directory to the specified path synchronously. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path. * @param options - Options for moving the directory. * @remarks If includeTrackedFiles is true, then it will execute the pending operations in the current directory. */ copyImmediatelySync(relativeOrAbsolutePath: string, options?: DirectoryCopyOptions): Directory; /** * Moves the directory to a new path. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path. * @param options - Options for moving the directory. */ move(relativeOrAbsolutePath: string, options?: DirectoryMoveOptions): this; /** * Immediately moves the directory to a new path asynchronously. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path. * @param options - Options for moving the directory. */ moveImmediately(relativeOrAbsolutePath: string, options?: DirectoryMoveOptions): Promise<this>; /** * Immediately moves the directory to a new path synchronously. * @param relativeOrAbsolutePath - Directory path as an absolute or relative path. * @param options - Options for moving the directory. */ moveImmediatelySync(relativeOrAbsolutePath: string, options?: DirectoryMoveOptions): this; /** * Queues a deletion of the directory to the file system. * * The directory will be deleted when calling ast.save(). If you wish to delete the file immediately, then use deleteImmediately(). */ delete(): void; /** * Asyncronously deletes the directory and all its descendants from the file system. */ deleteImmediately(): Promise<void>; /** * Synchronously deletes the directory and all its descendants from the file system. */ deleteImmediatelySync(): void; /** * Forgets the directory and all its descendants from the Project. * * Note: Does not delete the directory from the file system. */ forget(): void; /** * Asynchronously saves the directory and all the unsaved source files to the disk. */ save(): Promise<void>; /** * Synchronously saves the directory and all the unsaved source files to the disk. */ saveSync(): void; /** * Gets the relative path to another source file. * @param sourceFile - Source file. */ getRelativePathTo(sourceFile: SourceFile): string; /** * Gets the relative path to another directory. * @param directory - Directory. */ getRelativePathTo(directory: Directory): string; /** * Gets the relative path to the specified source file as a module specifier. * @param sourceFile - Source file. */ getRelativePathAsModuleSpecifierTo(sourceFile: SourceFile): string; /** * Gets the relative path to the specified directory as a module specifier. * @param directory - Directory. */ getRelativePathAsModuleSpecifierTo(directory: Directory): string; /** * Gets if the directory was forgotten. */ wasForgotten(): boolean; } export interface DirectoryAddOptions { /** * Whether to also recursively add all the directory's descendant directories. * @remarks Defaults to false. */ recursive?: boolean; } export interface DirectoryCopyOptions extends SourceFileCopyOptions { /** * Includes all the files in the directory and sub-directory when copying. * @remarks - Defaults to true. */ includeUntrackedFiles?: boolean; } 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[]; } export interface DirectoryMoveOptions extends SourceFileMoveOptions { } 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; move(srcPath: string, destPath: string): Promise<void>; moveSync(srcPath: string, destPath: string): void; copy(srcPath: string, destPath: string): Promise<void>; copySync(srcPath: string, destPath: 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 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; } /** * Project that holds source files. */ export declare class Project { /** * 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; /** Gets the compiler options for modification. */ readonly compilerOptions: CompilerOptionsContainer; /** * 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. * @param options - Options. */ addExistingDirectoryIfExists(dirPath: string, options?: DirectoryAddOptions): 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. * @param options - Options. * @throws DirectoryNotFoundError when the directory does not exist. */ addExistingDirectory(dirPath: string, options?: DirectoryAddOptions): Directory; /** * Creates a directory at the specified path. * @param dirPath - Path to create the directory at. */ createDirectory(dirPath: string): Directory; /** * Gets a directory by the specified path or throws if 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. * @param options - Options for adding the source file. * @returns The matched source files. */ addExistingSourceFiles(fileGlob: string, options?: SourceFileAddOptions): SourceFile[]; /** * Add source files based on file globs. * @param fileGlobs - File globs to add files based on. * @param options - Options for adding the source file. * @returns The matched source files. */ addExistingSourceFiles(fileGlobs: string[], options?: SourceFileAddOptions): 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. * @param options - Options for adding the source file. */ addExistingSourceFileIfExists(filePath: string, options?: SourceFileAddOptions): 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. * @param options - Options for adding the source file. * @throws FileNotFoundError when the file is not found. */ addExistingSourceFile(filePath: string, options?: SourceFileAddOptions): 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. * @param options - Options for adding the source file. */ addSourceFilesFromTsConfig(tsConfigFilePath: string, options?: SourceFileAddOptions): 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. * @param options - Options. * @throws - InvalidOperationError if a source file already exists at the provided file path. */ createSourceFile(filePath: string, sourceFileText: string, options?: SourceFileCreateOptions): 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. * @param options - Options. * @throws - InvalidOperationError if a source file already exists at the provided file path. */ createSourceFile(filePath: string, structure: SourceFileStructure, options?: SourceFileCreateOptions): 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 to the file system and deletes all deleted files. */ save(): Promise<void>; /** * Synchronously saves all the unsaved source files to the file system and deletes all deleted files. * * Remarks: This might be very slow compared to the asynchronous version if there are a lot of files. */ saveSync(): 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; /** * Creates a writer with the current manipulation settings. * @remarks Generally it's best to use a provided writer, but this may be useful in some scenarios. */ createWriter(): CodeBlockWriter; /** * 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 Project; export interface SourceFileAddOptions { languageVersion?: ScriptTarget; } export interface SourceFileCreateOptions extends SourceFileAddOptions { overwrite?: boolean; } export declare type Constructor<T> = new (...args: any[]) => T; export declare type WriterFunction = (writer: CodeBlockWriter) => void; /** * 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): CompilerNodeToWrappedType<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; } /** * 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 SourceFileReferencingNodes = ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration | CallExpression; export interface CompilerOptionsFromTsConfigOptions { encoding?: string; fileSystem?: FileSystemHost; } export interface CompilerOptionsFromTsConfigResult { options: CompilerOptions; errors: Diagnostic[]; } /** * Gets the compiler options from a specified tsconfig.json * @param filePath - File path to the tsconfig.json. * @param options - Options. */ export declare function getCompilerOptionsFromTsConfig(filePath: string, options?: CompilerOptionsFromTsConfigOptions): CompilerOptionsFromTsConfigResult; /** * 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 has a body. * @param node - Node to check. */ static hasBody(node: Node): node is Node & { getBody(): Node; }; /** * 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 AnyKeyword. * @param node - Node to check. */ static isAnyKeyword(node: Node): node is Expression; /** * 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 BooleanKeyword. * @param node - Node to check. */ static isBooleanKeyword(node: Node): node is Expression; /** * 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 ExclamationTokenableNode. * @param node - Node to check. */ static isExclamationTokenableNode(node: Node): node is ExclamationTokenableNode & Node; /** * 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 FalseKeyword. * @param node - Node to check. */ static isFalseKeyword(node: Node): node is BooleanLiteral; /** * 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 ImportTypeNode. * @param node - Node to check. */ static isImportTypeNode(node: Node): node is ImportTypeNode; /** * 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 JsxAttributedNode. * @param node - Node to check. */ static isJsxAttributedNode(node: Node): node is JsxAttributedNode & Node; /** * 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 JsxTagNamedNode. * @param node - Node to check. */ static isJsxTagNamedNode(node: Node): node is JsxTagNamedNode & Node; /** * 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 NeverKeyword. * @param node - Node to check. */ static isNeverKeyword(node: Node): node is Expression; /** * Gets if the