@rxap/schematics-ts-morph
Version:
This package provides utilities for manipulating TypeScript code using ts-morph, particularly for Angular and NestJS projects. It offers functions to add, coerce, and modify code elements like classes, methods, decorators, and imports. The package also in
17 lines • 734 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddClassMethod = AddClassMethod;
function AddClassMethod(classDeclaration, name, structure, overwrite) {
let methodDeclaration = classDeclaration.getMethod(name);
if (methodDeclaration) {
if (overwrite) {
methodDeclaration.remove();
}
else {
throw new Error('Can not add class method - a method with the same name already exists. Set the overwrite parameter to true or use CoerceClassMethod');
}
}
methodDeclaration = classDeclaration.addMethod(Object.assign(Object.assign({}, structure), { name }));
return methodDeclaration;
}
//# sourceMappingURL=add-class-method.js.map