UNPKG

ngx-unused

Version:

Detect unused classes (components, pipes, services and directives) defined in Angular workspace.

13 lines (12 loc) 785 B
import { SyntaxKind } from 'ts-morph'; export function getPropertyFromDecoratorCall(decorator, propertyName) { var _a; const decoratorCallArguments = decorator.getArguments(); const matchedProperty = decoratorCallArguments .flatMap(argument => argument .getProperties() .map(prop => prop.asKind(SyntaxKind.PropertyAssignment)) .filter(value => value !== undefined)) .find(structure => structure.getName() === propertyName); return (((_a = matchedProperty === null || matchedProperty === void 0 ? void 0 : matchedProperty.getInitializerIfKind(SyntaxKind.StringLiteral)) === null || _a === void 0 ? void 0 : _a.getLiteralValue()) || (matchedProperty === null || matchedProperty === void 0 ? void 0 : matchedProperty.getText())); }