@rxap/ts-morph
Version:
Provides utilities for manipulating TypeScript code using the ts-morph library. It offers a fluent API to add, modify, and remove code elements such as classes, decorators, imports, and properties in both Angular and NestJS projects. This package simplifi
16 lines • 654 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoercePropertyAssignment = CoercePropertyAssignment;
const ts_morph_1 = require("ts-morph");
function CoercePropertyAssignment(node, name, initializer, structure = {}) {
let property = node.getProperty(name);
if (!property) {
property = node.addPropertyAssignment({ initializer, name });
property.set(structure);
}
if (!property.isKind(ts_morph_1.SyntaxKind.PropertyAssignment)) {
throw new Error(`Property ${name} is not a PropertyAssignment`);
}
return property;
}
//# sourceMappingURL=coerce-property-assignment.js.map