File tree 2 files changed +19
-9
lines changed 2 files changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,22 @@ namespace ts {
129
129
return map ;
130
130
}
131
131
132
+ /**
133
+ * Creates a new array with `element` interspersed in between each element of `input`
134
+ * if there is more than 1 value in `input`. Otherwise, returns the existing array.
135
+ */
136
+ export function intersperse < T > ( input : T [ ] , element : T ) : T [ ] {
137
+ if ( input . length <= 1 ) {
138
+ return input ;
139
+ }
140
+ const result : T [ ] = [ ] ;
141
+ for ( let i = 0 , n = input . length ; i < n ; i ++ ) {
142
+ if ( i ) result . push ( element ) ;
143
+ result . push ( input [ i ] ) ;
144
+ }
145
+ return result ;
146
+ }
147
+
132
148
/**
133
149
* Iterates through `array` by index and performs the callback on each element of array until the callback
134
150
* returns a falsey value, then returns false.
Original file line number Diff line number Diff line change @@ -89,20 +89,14 @@ namespace ts.JsDoc {
89
89
// Eg. const a: Array<string> | Array<number>; a.length
90
90
// The property length will have two declarations of property length coming
91
91
// from Array<T> - Array<string> and Array<number>
92
- const documentationComment : SymbolDisplayPart [ ] = [ ] ;
92
+ const documentationComment : string [ ] = [ ] ;
93
93
forEachUnique ( declarations , declaration => {
94
94
for ( const { comment } of getCommentHavingNodes ( declaration ) ) {
95
95
if ( comment === undefined ) continue ;
96
- const commentTextPart = textPart ( comment ) ;
97
- if ( ! contains ( documentationComment , commentTextPart ) ) {
98
- if ( documentationComment . length ) {
99
- documentationComment . push ( lineBreakPart ( ) ) ;
100
- }
101
- documentationComment . push ( commentTextPart ) ;
102
- }
96
+ pushIfUnique ( documentationComment , comment ) ;
103
97
}
104
98
} ) ;
105
- return documentationComment ;
99
+ return intersperse ( map ( documentationComment , textPart ) , lineBreakPart ( ) ) ;
106
100
}
107
101
108
102
function getCommentHavingNodes ( declaration : Declaration ) : readonly ( JSDoc | JSDocTag ) [ ] {
You can’t perform that action at this time.
0 commit comments