@microsoft/api-extractor
Version:
Validate, document, and review the exported API for a TypeScript library
60 lines (58 loc) • 1.89 kB
JavaScript
;
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
const AstItem_1 = require("./AstItem");
/**
* This is an abstract base class for AstModule, AstEnum, and AstStructuredType,
* which all act as containers for other AstItem definitions.
*/
class AstItemContainer extends AstItem_1.default {
constructor(options) {
super(options);
this._memberItems = new Map();
}
/**
* Find a member in this namespace by name and return it if found.
*
* @param memberName - the name of the exported AstItem
*/
getMemberItem(memberName) {
return this._memberItems.get(memberName);
}
/**
* Return a list of the child items for this container, sorted alphabetically.
*/
getSortedMemberItems() {
const astItems = [];
this._memberItems.forEach((astItem) => {
astItems.push(astItem);
});
return astItems
.sort((a, b) => a.name.localeCompare(b.name));
}
/**
* @virtual
*/
visitTypeReferencesForAstItem() {
super.visitTypeReferencesForAstItem();
this._memberItems.forEach((astItem) => {
astItem.visitTypeReferencesForAstItem();
});
}
/**
* Add a child item to the container.
*/
addMemberItem(astItem) {
if (astItem.hasAnyIncompleteTypes()) {
this.reportWarning(`${astItem.name} has incomplete type information`);
}
else {
this.innerItems.push(astItem);
this._memberItems.set(astItem.name, astItem);
astItem.notifyAddedToContainer(this);
}
}
}
exports.default = AstItemContainer;
//# sourceMappingURL=AstItemContainer.js.map