Skip to main content
Module

x/ts_morph/ts_morph.d.ts>ModuledNode

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

Methods

addImportDeclaration(structure: OptionalKind<ImportDeclarationStructure>): ImportDeclaration

Adds an import.

addImportDeclarations(structures: ReadonlyArray<OptionalKind<ImportDeclarationStructure>>): ImportDeclaration[]

Adds imports.

insertImportDeclaration(index: number, structure: OptionalKind<ImportDeclarationStructure>): ImportDeclaration

Insert an import.

insertImportDeclarations(index: number, structures: ReadonlyArray<OptionalKind<ImportDeclarationStructure>>): ImportDeclaration[]

Inserts imports.

getImportDeclaration(condition: (importDeclaration: ImportDeclaration) => boolean): ImportDeclaration | undefined

Gets the first import declaration that matches a condition, or undefined if it doesn't exist.

getImportDeclaration(moduleSpecifier: string): ImportDeclaration | undefined

Gets the first import declaration that matches a module specifier, or undefined if it doesn't exist.

getImportDeclarationOrThrow(condition: (importDeclaration: ImportDeclaration) => boolean): ImportDeclaration

Gets the first import declaration that matches a condition, or throws if it doesn't exist.

getImportDeclarationOrThrow(moduleSpecifier: string): ImportDeclaration

Gets the first import declaration that matches a module specifier, or throws if it doesn't exist.

getImportDeclarations(): ImportDeclaration[]

Get the module's import declarations.

addExportDeclaration(structure: OptionalKind<ExportDeclarationStructure>): ExportDeclaration

Add export declarations.

addExportDeclarations(structures: ReadonlyArray<OptionalKind<ExportDeclarationStructure>>): ExportDeclaration[]

Add export declarations.

insertExportDeclaration(index: number, structure: OptionalKind<ExportDeclarationStructure>): ExportDeclaration

Insert an export declaration.

insertExportDeclarations(index: number, structures: ReadonlyArray<OptionalKind<ExportDeclarationStructure>>): ExportDeclaration[]

Insert export declarations.

getExportDeclaration(condition: (exportDeclaration: ExportDeclaration) => boolean): ExportDeclaration | undefined
getExportDeclaration(moduleSpecifier: string): ExportDeclaration | undefined

Gets the first export declaration that matches a module specifier, or undefined if it doesn't exist.

getExportDeclarationOrThrow(condition: (exportDeclaration: ExportDeclaration) => boolean): ExportDeclaration

Gets the first export declaration that matches a condition, or throws if it doesn't exist.

getExportDeclarationOrThrow(moduleSpecifier: string): ExportDeclaration

Gets the first export declaration that matches a module specifier, or throws if it doesn't exist.

getExportDeclarations(): ExportDeclaration[]

Get the export declarations.

addExportAssignment(structure: OptionalKind<ExportAssignmentStructure>): ExportAssignment

Add export assignments.

addExportAssignments(structures: ReadonlyArray<OptionalKind<ExportAssignmentStructure>>): ExportAssignment[]

Add export assignments.

insertExportAssignment(index: number, structure: OptionalKind<ExportAssignmentStructure>): ExportAssignment

Insert an export assignment.

insertExportAssignments(index: number, structures: ReadonlyArray<OptionalKind<ExportAssignmentStructure>>): ExportAssignment[]

Insert export assignments into a file.

getExportAssignment(condition: (exportAssignment: ExportAssignment) => boolean): ExportAssignment | undefined

Gets the first export assignment that matches a condition, or undefined if it doesn't exist.

getExportAssignmentOrThrow(condition: (exportAssignment: ExportAssignment) => boolean): ExportAssignment

Gets the first export assignment that matches a condition, or throws if it doesn't exist.

getExportAssignments(): ExportAssignment[]

Get the file's export assignments.

getDefaultExportSymbol(): Symbol | undefined

Gets the default export symbol.

getDefaultExportSymbolOrThrow(): Symbol

Gets the default export symbol or throws if it doesn't exist.

getExportSymbols(): Symbol[]

Gets the export symbols.

getExportedDeclarations(): ReadonlyMap<string, ExportedDeclarations[]>

Gets all the declarations that are exported from the module.

The key is the name it's exported on and the value is the array of declarations for that name.

This will include declarations that are transitively exported from other modules. If you mean to get the export declarations then use .getExportDeclarations().

removeDefaultExport(defaultExportSymbol?: Symbol | undefined): this

Removes any "export default".

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

Type Parameters

T extends Constructor<ModuledNodeExtensionType>