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

28 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CoerceMappingClassMethod = CoerceMappingClassMethod; const coerce_class_method_1 = require("./coerce-class-method"); const to_mapping_object_1 = require("./to-mapping-object"); function CoerceMappingClassMethod(sourceFile, classDeclaration, options) { var _a; const { parameterType, name, mapping, returnType, mappingOptions = {} } = options; (_a = mappingOptions.baseProperty) !== null && _a !== void 0 ? _a : (mappingOptions.baseProperty = 'input'); const { baseProperty } = mappingOptions; (0, coerce_class_method_1.CoerceClassMethod)(classDeclaration, name, { parameters: [ { name: baseProperty, type: parameterType, }, ], returnType: returnType, statements: mapping === true ? [`return ${baseProperty};`] : [ w => { w.write('return '); (0, to_mapping_object_1.ToMappingObject)(mapping, mappingOptions)(w); w.write(';'); }, ], }); } //# sourceMappingURL=coerce-mapping-class-method.js.map