UNPKG

@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

18 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetComponentDecoratorObject = GetComponentDecoratorObject; const ts_morph_1 = require("ts-morph"); const get_component_class_1 = require("./get-component-class"); function GetComponentDecoratorObject(sourceFileOrClassDeclaration) { const classDeclaration = sourceFileOrClassDeclaration.isKind(ts_morph_1.SyntaxKind.ClassDeclaration) ? sourceFileOrClassDeclaration : (0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration); const componentDecorator = classDeclaration.getDecorator('Component'); let componentOptions = componentDecorator.getArguments()[0]; if (!componentOptions) { componentOptions = componentDecorator.addArgument(ts_morph_1.Writers.object({})); } if (!(componentOptions.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression))) { throw new Error('The Component options is not an object literal expression'); } return componentOptions; } //# sourceMappingURL=get-component-decorator-object.js.map