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

24 lines 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CoerceModuleProvider = CoerceModuleProvider; const ts_morph_1 = require("ts-morph"); const add_provider_to_array_1 = require("../add-provider-to-array"); const get_coerce_array_literal_form_object_literal_1 = require("../get-coerce-array-literal-form-object-literal"); const get_component_class_1 = require("./get-component-class"); const get_component_decorator_object_1 = require("./get-component-decorator-object"); function CoerceModuleProvider(sourceFileOrClassDeclaration, providerObject) { let componentDecoratorObject; if (sourceFileOrClassDeclaration.isKind(ts_morph_1.SyntaxKind.ObjectLiteralExpression)) { componentDecoratorObject = sourceFileOrClassDeclaration; } else if (sourceFileOrClassDeclaration.isKind(ts_morph_1.SyntaxKind.ClassDeclaration)) { componentDecoratorObject = (0, get_component_decorator_object_1.GetComponentDecoratorObject)(sourceFileOrClassDeclaration); } else { componentDecoratorObject = (0, get_component_decorator_object_1.GetComponentDecoratorObject)((0, get_component_class_1.GetComponentClass)(sourceFileOrClassDeclaration)); } const providersArray = (0, get_coerce_array_literal_form_object_literal_1.GetCoerceArrayLiteralFromObjectLiteral)(componentDecoratorObject, 'providers'); (0, add_provider_to_array_1.AddProviderToArray)(providerObject, providersArray); return providersArray; } //# sourceMappingURL=coerce-module-provider.js.map