@@ -299,6 +299,9 @@ namespace ts {
299299 contextualGetAccessorDocumentationComment ?: SymbolDisplayPart [ ] ;
300300 contextualSetAccessorDocumentationComment ?: SymbolDisplayPart [ ] ;
301301
302+ contextualGetAccessorTags ?: JSDocTagInfo [ ] ;
303+ contextualSetAccessorTags ?: JSDocTagInfo [ ] ;
304+
302305 constructor ( flags : SymbolFlags , name : __String ) {
303306 this . flags = flags ;
304307 this . escapedName = name ;
@@ -343,13 +346,11 @@ namespace ts {
343346 switch ( context ?. kind ) {
344347 case SyntaxKind . GetAccessor :
345348 if ( ! this . contextualGetAccessorDocumentationComment ) {
346- this . contextualGetAccessorDocumentationComment = emptyArray ;
347349 this . contextualGetAccessorDocumentationComment = getDocumentationComment ( filter ( this . declarations , isGetAccessor ) , checker ) ;
348350 }
349351 return this . contextualGetAccessorDocumentationComment ;
350352 case SyntaxKind . SetAccessor :
351353 if ( ! this . contextualSetAccessorDocumentationComment ) {
352- this . contextualSetAccessorDocumentationComment = emptyArray ;
353354 this . contextualSetAccessorDocumentationComment = getDocumentationComment ( filter ( this . declarations , isSetAccessor ) , checker ) ;
354355 }
355356 return this . contextualSetAccessorDocumentationComment ;
@@ -360,11 +361,28 @@ namespace ts {
360361
361362 getJsDocTags ( checker ?: TypeChecker ) : JSDocTagInfo [ ] {
362363 if ( this . tags === undefined ) {
363- this . tags = JsDoc . getJsDocTagsFromDeclarations ( this . declarations , checker ) ;
364+ this . tags = getJsDocTagsOfDeclarations ( this . declarations , checker ) ;
364365 }
365366
366367 return this . tags ;
367368 }
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+ }
368386 }
369387
370388 class TokenObject < TKind extends SyntaxKind > extends TokenOrIdentifierObject implements Token < TKind > {
@@ -564,10 +582,7 @@ namespace ts {
564582 }
565583
566584 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 ) ) ;
571586 }
572587 }
573588
@@ -580,12 +595,25 @@ namespace ts {
580595 return getJSDocTags ( node ) . some ( tag => tag . tagName . text === "inheritDoc" ) ;
581596 }
582597
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+ }
589617 }
590618 }
591619 return tags ;
@@ -601,6 +629,9 @@ namespace ts {
601629 const inheritedDocs = findBaseOfDeclaration ( checker , declaration , symbol => {
602630 if ( ! seenSymbols . has ( symbol ) ) {
603631 seenSymbols . add ( symbol ) ;
632+ if ( declaration . kind === SyntaxKind . GetAccessor || declaration . kind === SyntaxKind . SetAccessor ) {
633+ return symbol . getContextualDocumentationComment ( declaration , checker ) ;
634+ }
604635 return symbol . getDocumentationComment ( checker ) ;
605636 }
606637 } ) ;
0 commit comments