UNPKG

ts-simple-ast

Version:

TypeScript compiler wrapper for AST navigation and code generation.

66 lines (65 loc) 2.21 kB
import * as ts from "typescript"; import { ImportSpecifierStructure } from "./../../structures"; import { Node, Identifier } from "./../common"; import { ImportSpecifier } from "./ImportSpecifier"; export declare class ImportDeclaration extends Node<ts.ImportDeclaration> { /** * Sets the import specifier. * @param text - Text to set as the import specifier. */ setModuleSpecifier(text: string): this; /** * Gets the module specifier. */ getModuleSpecifier(): string; /** * Sets the default import. * @param text - Text to set as the default import. */ setDefaultImport(text: string): this; /** * Gets the default import, if it exists. */ getDefaultImport(): Identifier | undefined; /** * Sets the namespace import. * @param text - Text to set as the namespace import. * @throws - InvalidOperationError if a named import exists. */ setNamespaceImport(text: string): this; /** * Gets the namespace import, if it exists. */ getNamespaceImport(): Identifier | undefined; /** * Add a named import. * @param structure - Structure that represents the named import. */ addNamedImport(structure: ImportSpecifierStructure): ImportSpecifier; /** * Add named imports. * @param structures - Structures that represent the named imports. */ addNamedImports(structures: ImportSpecifierStructure[]): ImportSpecifier[]; /** * Insert a named import. * @param index - Index to insert at. * @param structure - Structure that represents the named import. */ insertNamedImport(index: number, structure: ImportSpecifierStructure): ImportSpecifier; /** * Inserts named imports into the import declaration. * @param index - Index to insert at. * @param structures - Structures that represent the named imports. */ insertNamedImports(index: number, structures: ImportSpecifierStructure[]): ImportSpecifier[]; /** * Gets the named imports. */ getNamedImports(): ImportSpecifier[]; /** * Removes this import declaration. */ remove(): void; private getImportClause(); }