es-membrane

Home > ts-morph-structures > ImportManager

ImportManager class

This manages import declarations and specifiers, for including in a source file.

Signature:

export default class ImportManager 

Example

importsManager.addImports({
  pathToImportedModule: "ts-morph",
  isPackageImport: true,
  importNames: ["Structure", "StructureKind"],
  isDefaultImport: false,
  isTypeOnly: true
});
// ...
sourceFile.statements.unshift(...importsManager.getDeclarations());

Constructors

Constructor Modifiers Description
[(constructor)(absolutePathToModule)](/es-membrane/ts-morph-structures/api/ts-morph-structures.importmanager._constructor_.html) Constructs a new instance of the `ImportManager` class

Properties

Property Modifiers Type Description
[absolutePathToModule](/es-membrane/ts-morph-structures/api/ts-morph-structures.importmanager.absolutepathtomodule.html) `readonly` string Where the file will live on the file system.

Methods

Method Modifiers Description
[addImports(context)](/es-membrane/ts-morph-structures/api/ts-morph-structures.importmanager.addimports.html)
[getDeclarations()](/es-membrane/ts-morph-structures/api/ts-morph-structures.importmanager.getdeclarations.html) Get the import declarations, sorted by path to file, then internally by specified import values.