@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>
38 lines (37 loc) • 1.51 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefinedInParent = getDefinedInParent;
const ts_morph_1 = require("ts-morph");
/**
* Resolves the parent node (TypeReference or TypeAliasDeclaration name)
* of a property that is defined in a type alias declaration.
*
* Specifically, this resolves type alias declarations that resolve to types
* that are "object-like", including:
* - IntersectionTypes,
* - TypeLiterals, and
* - TypeReferences (which resolve to IntersectionTypes or TypeLiterals)
*
* For other types (e.g. UnionType) it just defaults back to the existing
* rendering.
*
* @param property
* @param currentNode
* @note
* Similar to `getMemberParent` but handling type aliases declarations
* rather than member inheritance.
*
* @see libs/builder/helpers/typescript/member/get-member-parent.ts
*/
function getDefinedInParent(property, currentNode) {
let propertyParent = property.getParent();
const excludeCurrentNode = (node) => node === currentNode ? undefined : node;
if (propertyParent?.isKind(ts_morph_1.SyntaxKind.TypeLiteral)) {
return excludeCurrentNode(getDefinedInParent(propertyParent, currentNode) ?? propertyParent);
}
if (propertyParent?.isKind(ts_morph_1.SyntaxKind.IntersectionType)) {
return excludeCurrentNode(getDefinedInParent(propertyParent, currentNode) ?? propertyParent);
}
return excludeCurrentNode(propertyParent);
}
//# sourceMappingURL=get-defined-in-parent.js.map
;