Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ts_morph/ts_morph.d.ts>ImportDeclaration

TypeScript Compiler API wrapper for static analysis and programmatic code changes.
Very Popular
Go to Latest
class ImportDeclaration
extends ImportDeclarationBase<ts.ImportDeclaration>
import { ImportDeclaration } from "https://deno.land/x/ts_morph@16.0.0/ts_morph.d.ts";

Methods

Adds named imports.

Gets the assert clause or returns undefined if it doesn't exist.

Gets the default import or returns undefined if it doesn't exist.

Gets the default import or throws if it doesn't exit.

Gets the import clause or returns undefined if it doesn't exist.

Gets the import clause or throws if it doesn't exist.

Gets the module specifier.

Gets the source file referenced in the module specifier or returns undefined if it can't find it.

Gets the source file referenced in the module specifier or throws if it can't find it.

Gets the module specifier string literal value.

Gets the named imports.

Gets the namespace import identifier, if it exists.

Gets the namespace import if it exists or throws.

getParent(): NodeParentType<ts.ImportDeclaration>
getParentOrThrow(): NonNullable<NodeParentType<ts.ImportDeclaration>>

Gets the structure equivalent to this node.

Inserts a named import.

insertNamedImports(index: number, namedImports: ReadonlyArray<OptionalKind<ImportSpecifierStructure> | string | WriterFunction> | WriterFunction): ImportSpecifier[]

Inserts named imports into the import declaration.

Gets if the module specifier starts with ./ or ../.

isTypeOnly(): boolean

Gets if this import declaration is type only.

Removes the default import.

Removes all the named imports.

Removes the namespace import.

renameDefaultImport(text: string): this

Renames or sets the provided default import.

set(structure: Partial<ImportDeclarationStructure>): this

Sets the node from a structure.

setAssertElements(elements: ReadonlyArray<OptionalKind<AssertEntryStructure>> | undefined): this

Sets the elements in an assert clause.

setDefaultImport(text: string): this

Sets the default import.

setIsTypeOnly(value: boolean): this

Sets if this import declaration is type only.

setModuleSpecifier(text: string): this

Sets the import specifier.

setModuleSpecifier(sourceFile: SourceFile): this

Sets the import specifier.

setNamespaceImport(text: string): this

Sets the namespace import.