@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
24 lines • 912 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoerceDecorator = CoerceDecorator;
const find_function_1 = require("./find-function");
/**
* @deprecated import from @rxap/ts-morph
*/
function CoerceDecorator(decoratableNode, structureOrName, structure = {}, compareTo = find_function_1.FindByNameFunction) {
let name;
if (typeof structureOrName === 'string') {
name = structureOrName;
}
else {
name = structureOrName.name;
structure = structureOrName !== null && structureOrName !== void 0 ? structureOrName : structure;
}
let decorator = decoratableNode.getDecorator(compareTo(Object.assign(Object.assign({}, structure), { name })));
if (!decorator) {
decorator = decoratableNode.addDecorator({ name });
decorator.set(structure);
}
return decorator;
}
//# sourceMappingURL=coerce-decorator.js.map