Skip to content

Commit ad17065

Browse files
committed
Fix a branch regression where setter-with-docs was not being reported
1 parent 679f621 commit ad17065

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

apps/api-extractor/src/collector/Collector.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,16 @@ export class Collector {
680680
private _calculateApiItemMetadata(astDeclaration: AstDeclaration): void {
681681
const declarationMetadata: InternalDeclarationMetadata = astDeclaration.declarationMetadata as InternalDeclarationMetadata;
682682
if (declarationMetadata.isAncillary) {
683+
684+
if (astDeclaration.declaration.kind === ts.SyntaxKind.SetAccessor) {
685+
if (declarationMetadata.tsdocParserContext) {
686+
this.messageRouter.addAnalyzerIssue(ExtractorMessageId.SetterWithDocs,
687+
`The doc comment for the property "${astDeclaration.astSymbol.localName}"`
688+
+ ` must appear on the getter, not the setter.`,
689+
astDeclaration);
690+
}
691+
}
692+
683693
// We never calculate ApiItemMetadata for an ancillary declaration; instead, it is assigned when
684694
// the main declaration is processed.
685695
return;

apps/api-extractor/src/enhancers/DocCommentEnhancer.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ export class DocCommentEnhancer {
3030
if (entity.astEntity instanceof AstSymbol) {
3131
if (entity.exported) {
3232
entity.astEntity.forEachDeclarationRecursive((astDeclaration: AstDeclaration) => {
33-
this._analyzeDeclaration(astDeclaration);
33+
this._analyzeApiItem(astDeclaration);
3434
});
3535
}
3636
}
3737
}
3838
}
3939

40-
private _analyzeDeclaration(astDeclaration: AstDeclaration): void {
40+
private _analyzeApiItem(astDeclaration: AstDeclaration): void {
4141
const metadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(astDeclaration);
4242
if (metadata.docCommentEnhancerVisitorState === VisitorState.Visited) {
4343
return;
@@ -130,16 +130,6 @@ export class DocCommentEnhancer {
130130
return;
131131
}
132132

133-
if (astDeclaration.declaration.kind === ts.SyntaxKind.SetAccessor) {
134-
if (metadata.tsdocComment) {
135-
this._collector.messageRouter.addAnalyzerIssue(ExtractorMessageId.SetterWithDocs,
136-
`The doc comment for the property "${astDeclaration.astSymbol.localName}"`
137-
+ ` must appear on the getter, not the setter.`,
138-
astDeclaration);
139-
}
140-
return;
141-
}
142-
143133
if (metadata.tsdocComment) {
144134
// Require the summary to contain at least 10 non-spacing characters
145135
metadata.needsDocumentation = !tsdoc.PlainTextEmitter.hasAnyTextContent(
@@ -215,7 +205,7 @@ export class DocCommentEnhancer {
215205
return;
216206
}
217207

218-
this._analyzeDeclaration(referencedAstDeclaration);
208+
this._analyzeApiItem(referencedAstDeclaration);
219209

220210
const referencedMetadata: ApiItemMetadata = this._collector.fetchApiItemMetadata(referencedAstDeclaration);
221211

0 commit comments

Comments
 (0)