@@ -299,6 +299,9 @@ namespace ts {
299
299
contextualGetAccessorDocumentationComment ?: SymbolDisplayPart [ ] ;
300
300
contextualSetAccessorDocumentationComment ?: SymbolDisplayPart [ ] ;
301
301
302
+ contextualGetAccessorTags ?: JSDocTagInfo [ ] ;
303
+ contextualSetAccessorTags ?: JSDocTagInfo [ ] ;
304
+
302
305
constructor ( flags : SymbolFlags , name : __String ) {
303
306
this . flags = flags ;
304
307
this . escapedName = name ;
@@ -343,13 +346,11 @@ namespace ts {
343
346
switch ( context ?. kind ) {
344
347
case SyntaxKind . GetAccessor :
345
348
if ( ! this . contextualGetAccessorDocumentationComment ) {
346
- this . contextualGetAccessorDocumentationComment = emptyArray ;
347
349
this . contextualGetAccessorDocumentationComment = getDocumentationComment ( filter ( this . declarations , isGetAccessor ) , checker ) ;
348
350
}
349
351
return this . contextualGetAccessorDocumentationComment ;
350
352
case SyntaxKind . SetAccessor :
351
353
if ( ! this . contextualSetAccessorDocumentationComment ) {
352
- this . contextualSetAccessorDocumentationComment = emptyArray ;
353
354
this . contextualSetAccessorDocumentationComment = getDocumentationComment ( filter ( this . declarations , isSetAccessor ) , checker ) ;
354
355
}
355
356
return this . contextualSetAccessorDocumentationComment ;
@@ -360,11 +361,28 @@ namespace ts {
360
361
361
362
getJsDocTags ( checker ?: TypeChecker ) : JSDocTagInfo [ ] {
362
363
if ( this . tags === undefined ) {
363
- this . tags = JsDoc . getJsDocTagsFromDeclarations ( this . declarations , checker ) ;
364
+ this . tags = getJsDocTagsOfDeclarations ( this . declarations , checker ) ;
364
365
}
365
366
366
367
return this . tags ;
367
368
}
369
+
370
+ getContextualJsDocTags ( context : Node | undefined , checker : TypeChecker | undefined ) : JSDocTagInfo [ ] {
371
+ switch ( context ?. kind ) {
372
+ case SyntaxKind . GetAccessor :
373
+ if ( ! this . contextualGetAccessorTags ) {
374
+ this . contextualGetAccessorTags = getJsDocTagsOfDeclarations ( filter ( this . declarations , isGetAccessor ) , checker ) ;
375
+ }
376
+ return this . contextualGetAccessorTags ;
377
+ case SyntaxKind . SetAccessor :
378
+ if ( ! this . contextualSetAccessorTags ) {
379
+ this . contextualSetAccessorTags = getJsDocTagsOfDeclarations ( filter ( this . declarations , isSetAccessor ) , checker ) ;
380
+ }
381
+ return this . contextualSetAccessorTags ;
382
+ default :
383
+ return this . getJsDocTags ( checker ) ;
384
+ }
385
+ }
368
386
}
369
387
370
388
class TokenObject < TKind extends SyntaxKind > extends TokenOrIdentifierObject implements Token < TKind > {
@@ -564,10 +582,7 @@ namespace ts {
564
582
}
565
583
566
584
getJsDocTags ( ) : JSDocTagInfo [ ] {
567
- if ( this . jsDocTags === undefined ) {
568
- this . jsDocTags = this . declaration ? getJsDocTagsOfSignature ( this . declaration , this . checker ) : [ ] ;
569
- }
570
- return this . jsDocTags ;
585
+ return this . jsDocTags || ( this . jsDocTags = getJsDocTagsOfDeclarations ( singleElementArray ( this . declaration ) , this . checker ) ) ;
571
586
}
572
587
}
573
588
@@ -580,12 +595,25 @@ namespace ts {
580
595
return getJSDocTags ( node ) . some ( tag => tag . tagName . text === "inheritDoc" ) ;
581
596
}
582
597
583
- function getJsDocTagsOfSignature ( declaration : Declaration , checker : TypeChecker ) : JSDocTagInfo [ ] {
584
- let tags = JsDoc . getJsDocTagsFromDeclarations ( [ declaration ] , checker ) ;
585
- if ( tags . length === 0 || hasJSDocInheritDocTag ( declaration ) ) {
586
- const inheritedTags = findBaseOfDeclaration ( checker , declaration , symbol => symbol . declarations ?. length === 1 ? symbol . getJsDocTags ( ) : undefined ) ;
587
- if ( inheritedTags ) {
588
- tags = [ ...inheritedTags , ...tags ] ;
598
+ function getJsDocTagsOfDeclarations ( declarations : Declaration [ ] | undefined , checker : TypeChecker | undefined ) : JSDocTagInfo [ ] {
599
+ if ( ! declarations ) return emptyArray ;
600
+
601
+ let tags = JsDoc . getJsDocTagsFromDeclarations ( declarations , checker ) ;
602
+ if ( checker && ( tags . length === 0 || declarations . some ( hasJSDocInheritDocTag ) ) ) {
603
+ const seenSymbols = new Set < Symbol > ( ) ;
604
+ for ( const declaration of declarations ) {
605
+ const inheritedTags = findBaseOfDeclaration ( checker , declaration , symbol => {
606
+ if ( ! seenSymbols . has ( symbol ) ) {
607
+ seenSymbols . add ( symbol ) ;
608
+ if ( declaration . kind === SyntaxKind . GetAccessor || declaration . kind === SyntaxKind . SetAccessor ) {
609
+ return symbol . getContextualJsDocTags ( declaration , checker ) ;
610
+ }
611
+ return symbol . declarations ?. length === 1 ? symbol . getJsDocTags ( ) : undefined ;
612
+ }
613
+ } ) ;
614
+ if ( inheritedTags ) {
615
+ tags = [ ...inheritedTags , ...tags ] ;
616
+ }
589
617
}
590
618
}
591
619
return tags ;
@@ -601,6 +629,9 @@ namespace ts {
601
629
const inheritedDocs = findBaseOfDeclaration ( checker , declaration , symbol => {
602
630
if ( ! seenSymbols . has ( symbol ) ) {
603
631
seenSymbols . add ( symbol ) ;
632
+ if ( declaration . kind === SyntaxKind . GetAccessor || declaration . kind === SyntaxKind . SetAccessor ) {
633
+ return symbol . getContextualDocumentationComment ( declaration , checker ) ;
634
+ }
604
635
return symbol . getDocumentationComment ( checker ) ;
605
636
}
606
637
} ) ;
0 commit comments