Skip to content

Commit

Permalink
Fix an issue where "ae-undocumented" was incorrectly reported for pri…
Browse files Browse the repository at this point in the history
…vate members
  • Loading branch information
octogonz committed Oct 13, 2023
1 parent 118feea commit ffe3f77
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions apps/api-extractor/src/generators/ApiReportGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class ApiReportGenerator {
): void {
// Should we process this declaration at all?
// eslint-disable-next-line no-bitwise
if ((astDeclaration.modifierFlags & ts.ModifierFlags.Private) !== 0) {
if (!ApiReportGenerator._shouldIncludeInReport(astDeclaration)) {
span.modification.skipAll();
return;
}
Expand Down Expand Up @@ -402,23 +402,27 @@ export class ApiReportGenerator {
astDeclaration
);

if (sortChildren) {
span.modification.sortChildren = true;
child.modification.sortKey = Collector.getSortKeyIgnoringUnderscore(
childAstDeclaration.astSymbol.localName
);
}
if (ApiReportGenerator._shouldIncludeInReport(childAstDeclaration)) {
if (sortChildren) {
span.modification.sortChildren = true;
child.modification.sortKey = Collector.getSortKeyIgnoringUnderscore(
childAstDeclaration.astSymbol.localName
);
}

if (!insideTypeLiteral) {
const messagesToReport: ExtractorMessage[] =
collector.messageRouter.fetchAssociatedMessagesForReviewFile(childAstDeclaration);
const aedocSynopsis: string = ApiReportGenerator._getAedocSynopsis(
collector,
childAstDeclaration,
messagesToReport
);
if (!insideTypeLiteral) {
const messagesToReport: ExtractorMessage[] =
collector.messageRouter.fetchAssociatedMessagesForReviewFile(childAstDeclaration);

child.modification.prefix = aedocSynopsis + child.modification.prefix;
// NOTE: This generates ae-undocumented messages as a side effect
const aedocSynopsis: string = ApiReportGenerator._getAedocSynopsis(
collector,
childAstDeclaration,
messagesToReport
);

child.modification.prefix = aedocSynopsis + child.modification.prefix;
}
}
}

Expand All @@ -427,6 +431,12 @@ export class ApiReportGenerator {
}
}

private static _shouldIncludeInReport(astDeclaration: AstDeclaration): boolean {
// Private declarations are not included in the API report
// eslint-disable-next-line no-bitwise
return (astDeclaration.modifierFlags & ts.ModifierFlags.Private) === 0;
}

/**
* For declarations marked as `@preapproved`, this is used instead of _modifySpan().
*/
Expand Down

0 comments on commit ffe3f77

Please sign in to comment.