@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
28 lines • 1.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetCoerceArrayLiteralFromObjectLiteral = GetCoerceArrayLiteralFromObjectLiteral;
const ts_morph_1 = require("ts-morph");
/**
* @deprecated import from @rxap/ts-morph
*/
function GetCoerceArrayLiteralFromObjectLiteral(objectLiteral, propertyKey) {
let arrayLiteralAssignment = objectLiteral.getProperty(propertyKey);
if (!arrayLiteralAssignment) {
arrayLiteralAssignment = objectLiteral.addPropertyAssignment({
name: propertyKey,
initializer: '[]',
});
}
if (!(arrayLiteralAssignment.isKind(ts_morph_1.SyntaxKind.PropertyAssignment))) {
throw new Error('The imports property is not type of Property Assignment!');
}
const arrayLiteral = arrayLiteralAssignment.getInitializer();
if (!arrayLiteral) {
throw new Error('The imports property a not a initializer');
}
if (!(arrayLiteral.isKind(ts_morph_1.SyntaxKind.ArrayLiteralExpression))) {
throw new Error('The imports property initializer is not an array');
}
return arrayLiteral;
}
//# sourceMappingURL=get-coerce-array-literal-form-object-literal.js.map