Skip to content

Commit 7584e6a

Browse files
authored
fix(49642): resolve JsDoc comments/tags if accessors exist in symbol declarations (#49654)
1 parent 94a6576 commit 7584e6a

3 files changed

Lines changed: 763 additions & 14 deletions

File tree

src/services/services.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -343,20 +343,25 @@ namespace ts {
343343
}
344344

345345
getContextualDocumentationComment(context: Node | undefined, checker: TypeChecker | undefined): SymbolDisplayPart[] {
346-
switch (context?.kind) {
347-
case SyntaxKind.GetAccessor:
346+
if (context) {
347+
if (isGetAccessor(context)) {
348348
if (!this.contextualGetAccessorDocumentationComment) {
349349
this.contextualGetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isGetAccessor), checker);
350350
}
351-
return this.contextualGetAccessorDocumentationComment;
352-
case SyntaxKind.SetAccessor:
351+
if (length(this.contextualGetAccessorDocumentationComment)) {
352+
return this.contextualGetAccessorDocumentationComment;
353+
}
354+
}
355+
if (isSetAccessor(context)) {
353356
if (!this.contextualSetAccessorDocumentationComment) {
354357
this.contextualSetAccessorDocumentationComment = getDocumentationComment(filter(this.declarations, isSetAccessor), checker);
355358
}
356-
return this.contextualSetAccessorDocumentationComment;
357-
default:
358-
return this.getDocumentationComment(checker);
359+
if (length(this.contextualSetAccessorDocumentationComment)) {
360+
return this.contextualSetAccessorDocumentationComment;
361+
}
362+
}
359363
}
364+
return this.getDocumentationComment(checker);
360365
}
361366

362367
getJsDocTags(checker?: TypeChecker): JSDocTagInfo[] {
@@ -368,20 +373,25 @@ namespace ts {
368373
}
369374

370375
getContextualJsDocTags(context: Node | undefined, checker: TypeChecker | undefined): JSDocTagInfo[] {
371-
switch (context?.kind) {
372-
case SyntaxKind.GetAccessor:
376+
if (context) {
377+
if (isGetAccessor(context)) {
373378
if (!this.contextualGetAccessorTags) {
374379
this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(filter(this.declarations, isGetAccessor), checker);
375380
}
376-
return this.contextualGetAccessorTags;
377-
case SyntaxKind.SetAccessor:
381+
if (length(this.contextualGetAccessorTags)) {
382+
return this.contextualGetAccessorTags;
383+
}
384+
}
385+
if (isSetAccessor(context)) {
378386
if (!this.contextualSetAccessorTags) {
379387
this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(filter(this.declarations, isSetAccessor), checker);
380388
}
381-
return this.contextualSetAccessorTags;
382-
default:
383-
return this.getJsDocTags(checker);
389+
if (length(this.contextualSetAccessorTags)) {
390+
return this.contextualSetAccessorTags;
391+
}
392+
}
384393
}
394+
return this.getJsDocTags(checker);
385395
}
386396
}
387397

0 commit comments

Comments
 (0)