@@ -579,20 +579,24 @@ namespace ts {
579
579
function getDocumentationComment ( declarations : readonly Declaration [ ] | undefined , checker : TypeChecker | undefined ) : SymbolDisplayPart [ ] {
580
580
if ( ! declarations ) return emptyArray ;
581
581
582
- const docsSet = new Set < string > ( ) ;
583
- JsDoc . getJsDocCommentsFromDeclarations ( declarations ) . forEach ( value => docsSet . add ( value . text ) ) ;
584
- if ( checker && ( docsSet . size === 0 || declarations . some ( hasJSDocInheritDocTag ) ) ) {
582
+ let doc = JsDoc . getJsDocCommentsFromDeclarations ( declarations ) ;
583
+ if ( checker && ( doc . length === 0 || declarations . some ( hasJSDocInheritDocTag ) ) ) {
585
584
forEachUnique ( declarations , declaration => {
586
- const inheritedDocs = findBaseOfDeclaration ( checker , declaration , symbol => {
587
- return symbol . getDocumentationComment ( checker )
588
- } ) ;
589
- // TODO: GH#16312 Return a ReadonlyArray, avoid copying
590
- if ( inheritedDocs ) inheritedDocs . forEach ( value => docsSet . add ( value . text ) )
585
+ const inheritedDocs = findBaseOfDeclaration ( checker , declaration , symbol => symbol . getDocumentationComment ( checker ) ) ;
586
+ // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs
587
+ if ( inheritedDocs ) {
588
+ if ( doc . length === 0 ) doc = inheritedDocs . slice ( ) ;
589
+ else {
590
+ for ( const docValue of doc ) {
591
+ if ( docValue . text !== "\n" && ! inheritedDocs . some ( value => value . text === docValue . text ) ) {
592
+ inheritedDocs . push ( lineBreakPart ( ) , docValue ) ;
593
+ }
594
+ }
595
+ doc = inheritedDocs ;
596
+ } ;
597
+ } ;
591
598
} ) ;
592
599
}
593
- let doc : SymbolDisplayPart [ ] = [ ] ;
594
- docsSet . forEach ( value => doc . push ( { text : value , kind : "text" } ) )
595
- if ( doc . length > 1 ) doc = doc . map ( ( e , i ) => i < doc . length - 1 && e . text !== "" ? [ e , lineBreakPart ( ) ] : [ e ] ) . reduce ( ( a , b ) => a . concat ( b ) )
596
600
return doc ;
597
601
}
598
602
0 commit comments