UNPKG

@ng-doc/builder

Version:

<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>

37 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDemoClassDeclarations = getDemoClassDeclarations; const core_1 = require("@ng-doc/core"); const ts_morph_1 = require("ts-morph"); /** * * @param objectExpression */ function getDemoClassDeclarations(objectExpression) { const demoProperty = objectExpression.getProperty('demos'); if (demoProperty && (ts_morph_1.Node.isPropertyAssignment(demoProperty) || ts_morph_1.Node.isShorthandPropertyAssignment(demoProperty))) { const initializer = demoProperty.getInitializer(); if (ts_morph_1.Node.isObjectLiteralExpression(initializer)) { return initializer .getProperties() .reduce((acc, property) => { const classDeclaration = property.getType().getSymbol()?.getValueDeclaration(); if (ts_morph_1.Node.isClassDeclaration(classDeclaration)) { if (ts_morph_1.Node.isShorthandPropertyAssignment(property) && classDeclaration.getName()) { const className = classDeclaration.getName(); if ((0, core_1.isPresent)(className)) { acc[className] = classDeclaration; } } else if (ts_morph_1.Node.isPropertyAssignment(property)) { acc[property.getName()] = classDeclaration; } } return acc; }, {}); } } return {}; } //# sourceMappingURL=get-demo-class-declarations.js.map