@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 • 964 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HasConstructorParameter = HasConstructorParameter;
/**
* Checks if a constructor parameter with the given name exists in a class.
*
* @param {ClassDeclaration} classDeclaration - The class declaration to check.
* @param {string} parameterName - The name of the constructor parameter.
* @param {boolean} isAlsoClassMember - Optional. Determines if only constructor parameter that are also class members are checked. Default is false.
* @returns {boolean} - True if a constructor parameter with the given name exists, false otherwise.
*/
function HasConstructorParameter(classDeclaration, parameterName, isAlsoClassMember = false) {
return classDeclaration.getConstructors().some(cotr => cotr.getParameters()
.some(param => (!isAlsoClassMember || !!param.getScope()) && param.getName() === parameterName));
}
//# sourceMappingURL=has-constructor-parameter.js.map