Skip to content

Commit d861d22

Browse files
authored
Merge pull request #4392 from microsoft/octogonz/ae-undocumented-fix
[api-extractor] Fix an issue where "ae-undocumented" was incorrectly reported for private members
2 parents 2e26d1f + c87ac33 commit d861d22

File tree

4 files changed

+57
-27
lines changed

4 files changed

+57
-27
lines changed

apps/api-extractor/build-tests.cmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@ECHO OFF
22
@SETLOCAL
3-
rush test -t api-extractor-lib1-test -t api-extractor-lib2-test -t api-extractor-lib3-test -t api-extractor-scenarios -t api-extractor-test-01 -t api-extractor-test-02 -t api-extractor-test-03 -t api-extractor-test-04 -t api-documenter-test
3+
rush test -t tag:api-extractor-tests

apps/api-extractor/src/generators/ApiReportGenerator.ts

+26-16
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export class ApiReportGenerator {
259259
): void {
260260
// Should we process this declaration at all?
261261
// eslint-disable-next-line no-bitwise
262-
if ((astDeclaration.modifierFlags & ts.ModifierFlags.Private) !== 0) {
262+
if (!ApiReportGenerator._shouldIncludeInReport(astDeclaration)) {
263263
span.modification.skipAll();
264264
return;
265265
}
@@ -402,23 +402,27 @@ export class ApiReportGenerator {
402402
astDeclaration
403403
);
404404

405-
if (sortChildren) {
406-
span.modification.sortChildren = true;
407-
child.modification.sortKey = Collector.getSortKeyIgnoringUnderscore(
408-
childAstDeclaration.astSymbol.localName
409-
);
410-
}
405+
if (ApiReportGenerator._shouldIncludeInReport(childAstDeclaration)) {
406+
if (sortChildren) {
407+
span.modification.sortChildren = true;
408+
child.modification.sortKey = Collector.getSortKeyIgnoringUnderscore(
409+
childAstDeclaration.astSymbol.localName
410+
);
411+
}
411412

412-
if (!insideTypeLiteral) {
413-
const messagesToReport: ExtractorMessage[] =
414-
collector.messageRouter.fetchAssociatedMessagesForReviewFile(childAstDeclaration);
415-
const aedocSynopsis: string = ApiReportGenerator._getAedocSynopsis(
416-
collector,
417-
childAstDeclaration,
418-
messagesToReport
419-
);
413+
if (!insideTypeLiteral) {
414+
const messagesToReport: ExtractorMessage[] =
415+
collector.messageRouter.fetchAssociatedMessagesForReviewFile(childAstDeclaration);
420416

421-
child.modification.prefix = aedocSynopsis + child.modification.prefix;
417+
// NOTE: This generates ae-undocumented messages as a side effect
418+
const aedocSynopsis: string = ApiReportGenerator._getAedocSynopsis(
419+
collector,
420+
childAstDeclaration,
421+
messagesToReport
422+
);
423+
424+
child.modification.prefix = aedocSynopsis + child.modification.prefix;
425+
}
422426
}
423427
}
424428

@@ -427,6 +431,12 @@ export class ApiReportGenerator {
427431
}
428432
}
429433

434+
private static _shouldIncludeInReport(astDeclaration: AstDeclaration): boolean {
435+
// Private declarations are not included in the API report
436+
// eslint-disable-next-line no-bitwise
437+
return (astDeclaration.modifierFlags & ts.ModifierFlags.Private) === 0;
438+
}
439+
430440
/**
431441
* For declarations marked as `@preapproved`, this is used instead of _modifySpan().
432442
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/api-extractor",
5+
"comment": "Fix an issue where \"ae-undocumented\" was incorrectly reported for private members",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@microsoft/api-extractor"
10+
}

rush.json

+20-10
Original file line numberDiff line numberDiff line change
@@ -483,61 +483,71 @@
483483
"packageName": "api-documenter-test",
484484
"projectFolder": "build-tests/api-documenter-test",
485485
"reviewCategory": "tests",
486-
"shouldPublish": false
486+
"shouldPublish": false,
487+
"tags": ["api-extractor-tests"]
487488
},
488489
{
489490
"packageName": "api-documenter-scenarios",
490491
"projectFolder": "build-tests/api-documenter-scenarios",
491492
"reviewCategory": "tests",
492-
"shouldPublish": false
493+
"shouldPublish": false,
494+
"tags": ["api-extractor-tests"]
493495
},
494496
{
495497
"packageName": "api-extractor-lib1-test",
496498
"projectFolder": "build-tests/api-extractor-lib1-test",
497499
"reviewCategory": "tests",
498-
"shouldPublish": false
500+
"shouldPublish": false,
501+
"tags": ["api-extractor-tests"]
499502
},
500503
{
501504
"packageName": "api-extractor-lib2-test",
502505
"projectFolder": "build-tests/api-extractor-lib2-test",
503506
"reviewCategory": "tests",
504-
"shouldPublish": false
507+
"shouldPublish": false,
508+
"tags": ["api-extractor-tests"]
505509
},
506510
{
507511
"packageName": "api-extractor-lib3-test",
508512
"projectFolder": "build-tests/api-extractor-lib3-test",
509513
"reviewCategory": "tests",
510-
"shouldPublish": false
514+
"shouldPublish": false,
515+
"tags": ["api-extractor-tests"]
511516
},
512517
{
513518
"packageName": "api-extractor-scenarios",
514519
"projectFolder": "build-tests/api-extractor-scenarios",
515520
"reviewCategory": "tests",
516-
"shouldPublish": false
521+
"shouldPublish": false,
522+
"tags": ["api-extractor-tests"]
517523
},
518524
{
519525
"packageName": "api-extractor-test-01",
520526
"projectFolder": "build-tests/api-extractor-test-01",
521527
"reviewCategory": "tests",
522-
"shouldPublish": false
528+
"shouldPublish": false,
529+
"tags": ["api-extractor-tests"]
523530
},
524531
{
525532
"packageName": "api-extractor-test-02",
526533
"projectFolder": "build-tests/api-extractor-test-02",
527534
"reviewCategory": "tests",
528-
"shouldPublish": false
535+
"shouldPublish": false,
536+
"tags": ["api-extractor-tests"]
529537
},
530538
{
531539
"packageName": "api-extractor-test-03",
532540
"projectFolder": "build-tests/api-extractor-test-03",
533541
"reviewCategory": "tests",
534-
"shouldPublish": false
542+
"shouldPublish": false,
543+
"tags": ["api-extractor-tests"]
535544
},
536545
{
537546
"packageName": "api-extractor-test-04",
538547
"projectFolder": "build-tests/api-extractor-test-04",
539548
"reviewCategory": "tests",
540-
"shouldPublish": false
549+
"shouldPublish": false,
550+
"tags": ["api-extractor-tests"]
541551
},
542552
{
543553
"packageName": "eslint-7-7-test",

0 commit comments

Comments
 (0)