Comparing version 1.1.0 to 1.2.0
import { ClassDeclaration } from 'ts-morph'; | ||
export declare function addImportToModule(classDeclaration: ClassDeclaration, { moduleName, moduleSpecifier, element, }: { | ||
moduleName: string; | ||
moduleSpecifier: string; | ||
element?: string; | ||
}): void; | ||
export declare function addImportToModule(classDeclaration: ClassDeclaration, moduleName: string): void; |
@@ -6,6 +6,4 @@ "use strict"; | ||
const decorators_1 = require("ng-morph/decorators"); | ||
const imports_1 = require("ng-morph/imports"); | ||
function addImportToModule(classDeclaration, { moduleName, moduleSpecifier, element = moduleName, }) { | ||
function addImportToModule(classDeclaration, moduleName) { | ||
var _a; | ||
const file = classDeclaration.getSourceFile(); | ||
const [moduleDecorator] = decorators_1.getDecorators(classDeclaration, { | ||
@@ -26,16 +24,5 @@ name: 'NgModule', | ||
} | ||
importsInitializer.addElement(element); | ||
const [moduleImport = file.addImportDeclaration({ | ||
moduleSpecifier, | ||
namedImports: [moduleName], | ||
}),] = imports_1.getImports(file.getFilePath(), { | ||
moduleSpecifier, | ||
}); | ||
if (!moduleImport | ||
.getNamedImports() | ||
.find((namedImport) => namedImport.getName() === moduleName)) { | ||
moduleImport.addNamedImport(moduleName); | ||
} | ||
importsInitializer.addElement(moduleName); | ||
} | ||
exports.addImportToModule = addImportToModule; | ||
//# sourceMappingURL=add-import-to-module.js.map |
{ | ||
"name": "ng-morph", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"peerDependencies": { | ||
@@ -5,0 +5,0 @@ "@angular-devkit/core": ">=11.0.0", |
Sorry, the diff of this file is not supported yet
140381
1914