Home > ts-morph-structures > ImportManager
This manages import declarations and specifiers, for including in a source file.
Signature:
export default class ImportManager
importsManager.addImports({
pathToImportedModule: "ts-morph",
isPackageImport: true,
importNames: ["Structure", "StructureKind"],
isDefaultImport: false,
isTypeOnly: true
});
// ...
sourceFile.statements.unshift(...importsManager.getDeclarations());
Constructor | Modifiers | Description |
---|---|---|
(constructor)(absolutePathToModule) | Constructs a new instance of the ImportManager class |
Property | Modifiers | Type | Description |
---|---|---|---|
absolutePathToModule | readonly |
string | Where the file will live on the file system. |
Method | Modifiers | Description |
---|---|---|
addImports(context) | ||
getDeclarations() | Get the import declarations, sorted by path to file, then internally by specified import values. |