Skip to main content
Module

x/ts_morph/ts_morph.d.ts>StatementedNode

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
Very Popular
Go to Latest
interface StatementedNode
import { type StatementedNode } from "https://deno.land/x/ts_morph@15.1.0/ts_morph.d.ts";

Methods

getStatements(): Statement[]

Gets the node's statements.

getStatementsWithComments(): Statement[]

Gets the node's statements with comment statements.

getStatement<T extends Statement>(findFunction: (statement: Statement) => statement is T): T | undefined

Gets the first statement that matches the provided condition or returns undefined if it doesn't exist.

getStatement(findFunction: (statement: Statement) => boolean): Statement | undefined

Gets the first statement that matches the provided condition or returns undefined if it doesn't exist.

getStatementOrThrow<T extends Statement>(findFunction: (statement: Statement) => statement is T): T

Gets the first statement that matches the provided condition or throws if it doesn't exist.

getStatementOrThrow(findFunction: (statement: Statement) => boolean): Statement

Gets the first statement that matches the provided condition or throws if it doesn't exist.

getStatementByKind<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappingsWithCommentStatements[TKind] | undefined

Gets the first statement that matches the provided syntax kind or returns undefined if it doesn't exist.

getStatementByKindOrThrow<TKind extends SyntaxKind>(kind: TKind): KindToNodeMappingsWithCommentStatements[TKind]

Gets the first statement that matches the provided syntax kind or throws if it doesn't exist.

addStatements(statements: string | WriterFunction | ReadonlyArray<string | WriterFunction | StatementStructures>): Statement[]

Add statements.

insertStatements(index: number, statements: string | WriterFunction | ReadonlyArray<string | WriterFunction | StatementStructures>): Statement[]

Inserts statements at the specified index.

removeStatement(index: number): this

Removes the statement at the specified index.

removeStatements(indexRange: [number, number]): this

Removes the statements at the specified index range.

Adds an class declaration as a child.

addClasses(structures: ReadonlyArray<OptionalKind<ClassDeclarationStructure>>): ClassDeclaration[]

Adds class declarations as a child.

insertClass(index: number, structure: OptionalKind<ClassDeclarationStructure>): ClassDeclaration

Inserts an class declaration as a child.

insertClasses(index: number, structures: ReadonlyArray<OptionalKind<ClassDeclarationStructure>>): ClassDeclaration[]

Inserts class declarations as a child.

getClasses(): ClassDeclaration[]

Gets the direct class declaration children.

getClass(name: string): ClassDeclaration | undefined

Gets a class.

getClass(findFunction: (declaration: ClassDeclaration) => boolean): ClassDeclaration | undefined

Gets a class.

getClassOrThrow(name: string): ClassDeclaration

Gets a class or throws if it doesn't exist.

getClassOrThrow(findFunction: (declaration: ClassDeclaration) => boolean): ClassDeclaration

Gets a class or throws if it doesn't exist.

Adds an enum declaration as a child.

addEnums(structures: ReadonlyArray<OptionalKind<EnumDeclarationStructure>>): EnumDeclaration[]

Adds enum declarations as a child.

insertEnum(index: number, structure: OptionalKind<EnumDeclarationStructure>): EnumDeclaration

Inserts an enum declaration as a child.

insertEnums(index: number, structures: ReadonlyArray<OptionalKind<EnumDeclarationStructure>>): EnumDeclaration[]

Inserts enum declarations as a child.

getEnums(): EnumDeclaration[]

Gets the direct enum declaration children.

getEnum(name: string): EnumDeclaration | undefined

Gets an enum.

getEnum(findFunction: (declaration: EnumDeclaration) => boolean): EnumDeclaration | undefined

Gets an enum.

getEnumOrThrow(name: string): EnumDeclaration

Gets an enum or throws if it doesn't exist.

getEnumOrThrow(findFunction: (declaration: EnumDeclaration) => boolean): EnumDeclaration

Gets an enum or throws if it doesn't exist.

Adds a function declaration as a child.

addFunctions(structures: ReadonlyArray<OptionalKind<FunctionDeclarationStructure>>): FunctionDeclaration[]

Adds function declarations as a child.

insertFunction(index: number, structure: OptionalKind<FunctionDeclarationStructure>): FunctionDeclaration

Inserts an function declaration as a child.

insertFunctions(index: number, structures: ReadonlyArray<OptionalKind<FunctionDeclarationStructure>>): FunctionDeclaration[]

Inserts function declarations as a child.

getFunctions(): FunctionDeclaration[]

Gets the direct function declaration children.

getFunction(name: string): FunctionDeclaration | undefined

Gets a function.

getFunction(findFunction: (declaration: FunctionDeclaration) => boolean): FunctionDeclaration | undefined

Gets a function.

getFunctionOrThrow(name: string): FunctionDeclaration

Gets a function or throws if it doesn't exist.

getFunctionOrThrow(findFunction: (declaration: FunctionDeclaration) => boolean): FunctionDeclaration

Gets a function or throws if it doesn't exist.

Adds a interface declaration as a child.

addInterfaces(structures: ReadonlyArray<OptionalKind<InterfaceDeclarationStructure>>): InterfaceDeclaration[]

Adds interface declarations as a child.

insertInterface(index: number, structure: OptionalKind<InterfaceDeclarationStructure>): InterfaceDeclaration

Inserts an interface declaration as a child.

insertInterfaces(index: number, structures: ReadonlyArray<OptionalKind<InterfaceDeclarationStructure>>): InterfaceDeclaration[]

Inserts interface declarations as a child.

getInterfaces(): InterfaceDeclaration[]

Gets the direct interface declaration children.

getInterface(name: string): InterfaceDeclaration | undefined

Gets an interface.

getInterface(findFunction: (declaration: InterfaceDeclaration) => boolean): InterfaceDeclaration | undefined

Gets an interface.

getInterfaceOrThrow(name: string): InterfaceDeclaration

Gets an interface or throws if it doesn't exist.

getInterfaceOrThrow(findFunction: (declaration: InterfaceDeclaration) => boolean): InterfaceDeclaration

Gets an interface or throws if it doesn't exist.

Adds a module declaration as a child.

addModules(structures: ReadonlyArray<OptionalKind<ModuleDeclarationStructure>>): ModuleDeclaration[]

Adds module declarations as a child.

insertModule(index: number, structure: OptionalKind<ModuleDeclarationStructure>): ModuleDeclaration

Inserts a module declaration as a child.

insertModules(index: number, structures: ReadonlyArray<OptionalKind<ModuleDeclarationStructure>>): ModuleDeclaration[]

Inserts module declarations as children.

getModules(): ModuleDeclaration[]

Gets the module declaration children.

getModule(name: string): ModuleDeclaration | undefined

Gets a module declaration child by name.

getModule(findFunction: (declaration: ModuleDeclaration) => boolean): ModuleDeclaration | undefined

Gets a module declaration child by condition.

getModuleOrThrow(name: string): ModuleDeclaration

Gets a module declaration child by name or throws if it doesn't exist.

getModuleOrThrow(findFunction: (declaration: ModuleDeclaration) => boolean): ModuleDeclaration

Gets a module declaration child by condition or throws if it doesn't exist.

Adds a type alias declaration as a child.

addTypeAliases(structures: ReadonlyArray<OptionalKind<TypeAliasDeclarationStructure>>): TypeAliasDeclaration[]

Adds type alias declarations as a child.

insertTypeAlias(index: number, structure: OptionalKind<TypeAliasDeclarationStructure>): TypeAliasDeclaration

Inserts an type alias declaration as a child.

insertTypeAliases(index: number, structures: ReadonlyArray<OptionalKind<TypeAliasDeclarationStructure>>): TypeAliasDeclaration[]

Inserts type alias declarations as a child.

getTypeAliases(): TypeAliasDeclaration[]

Gets the direct type alias declaration children.

getTypeAlias(name: string): TypeAliasDeclaration | undefined

Gets a type alias.

getTypeAlias(findFunction: (declaration: TypeAliasDeclaration) => boolean): TypeAliasDeclaration | undefined

Gets a type alias.

getTypeAliasOrThrow(name: string): TypeAliasDeclaration

Gets a type alias or throws if it doesn't exist.

getTypeAliasOrThrow(findFunction: (declaration: TypeAliasDeclaration) => boolean): TypeAliasDeclaration

Gets a type alias or throws if it doesn't exist.

addVariableStatement(structure: OptionalKind<VariableStatementStructure>): VariableStatement

Adds a variable statement.

addVariableStatements(structures: ReadonlyArray<OptionalKind<VariableStatementStructure>>): VariableStatement[]

Adds variable statements.

insertVariableStatement(index: number, structure: OptionalKind<VariableStatementStructure>): VariableStatement

Inserts a variable statement.

insertVariableStatements(index: number, structures: ReadonlyArray<OptionalKind<VariableStatementStructure>>): VariableStatement[]

Inserts variable statements.

getVariableStatements(): VariableStatement[]

Gets the direct variable statement children.

getVariableStatement(name: string): VariableStatement | undefined

Gets a variable statement.

getVariableStatement(findFunction: (declaration: VariableStatement) => boolean): VariableStatement | undefined

Gets a variable statement.

getVariableStatementOrThrow(name: string): VariableStatement

Gets a variable statement or throws if it doesn't exist.

getVariableStatementOrThrow(findFunction: (declaration: VariableStatement) => boolean): VariableStatement

Gets a variable statement or throws if it doesn't exist.

getVariableDeclarations(): VariableDeclaration[]

Gets all the variable declarations within the variable statement children.

getVariableDeclaration(name: string): VariableDeclaration | undefined

Gets a variable declaration.

getVariableDeclaration(findFunction: (declaration: VariableDeclaration) => boolean): VariableDeclaration | undefined

Gets a variable declaration.

getVariableDeclarationOrThrow(name: string): VariableDeclaration

Gets a variable declaration or throws if it doesn't exist.

getVariableDeclarationOrThrow(findFunction: (declaration: VariableDeclaration) => boolean): VariableDeclaration

Gets a variable declaration or throws if it doesn't exist.

function StatementedNode
import { StatementedNode } from "https://deno.land/x/ts_morph@15.1.0/ts_morph.d.ts";

Type Parameters

T extends Constructor<StatementedNodeExtensionType>