File tree 4 files changed +108
-6
lines changed
4 files changed +108
-6
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,17 +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
- if ( documentationComment . length ) {
97
- documentationComment . push ( lineBreakPart ( ) ) ;
98
- }
99
- documentationComment . push ( textPart ( comment ) ) ;
96
+ pushIfUnique ( documentationComment , comment ) ;
100
97
}
101
98
} ) ;
102
- return documentationComment ;
99
+ return intersperse ( map ( documentationComment , textPart ) , lineBreakPart ( ) ) ;
103
100
}
104
101
105
102
function getCommentHavingNodes ( declaration : Declaration ) : readonly ( JSDoc | JSDocTag ) [ ] {
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "marker": {
4
+ "fileName": "/tests/cases/fourslash/quickInfoOnUnionPropertiesWithIdenticalJSDocComments01.ts",
5
+ "position": 746
6
+ },
7
+ "quickInfo": {
8
+ "kind": "property",
9
+ "kindModifiers": "optional",
10
+ "textSpan": {
11
+ "start": 746,
12
+ "length": 8
13
+ },
14
+ "displayParts": [
15
+ {
16
+ "text": "(",
17
+ "kind": "punctuation"
18
+ },
19
+ {
20
+ "text": "property",
21
+ "kind": "text"
22
+ },
23
+ {
24
+ "text": ")",
25
+ "kind": "punctuation"
26
+ },
27
+ {
28
+ "text": " ",
29
+ "kind": "space"
30
+ },
31
+ {
32
+ "text": "language",
33
+ "kind": "propertyName"
34
+ },
35
+ {
36
+ "text": "?",
37
+ "kind": "punctuation"
38
+ },
39
+ {
40
+ "text": ":",
41
+ "kind": "punctuation"
42
+ },
43
+ {
44
+ "text": " ",
45
+ "kind": "space"
46
+ },
47
+ {
48
+ "text": "string",
49
+ "kind": "keyword"
50
+ }
51
+ ],
52
+ "documentation": [
53
+ {
54
+ "text": "A language id, like `typescript`.",
55
+ "kind": "text"
56
+ }
57
+ ]
58
+ }
59
+ }
60
+ ]
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ ////export type DocumentFilter = {
4
+ //// /** A language id, like `typescript`. */
5
+ //// language: string;
6
+ //// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
7
+ //// scheme?: string;
8
+ //// /** A glob pattern, like `*.{ts,js}`. */
9
+ //// pattern?: string;
10
+ //// } | {
11
+ //// /** A language id, like `typescript`. */
12
+ //// language?: string;
13
+ //// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
14
+ //// scheme: string;
15
+ //// /** A glob pattern, like `*.{ts,js}`. */
16
+ //// pattern?: string;
17
+ //// } | {
18
+ //// /** A language id, like `typescript`. */
19
+ //// language?: string;
20
+ //// /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
21
+ //// scheme?: string;
22
+ //// /** A glob pattern, like `*.{ts,js}`. */
23
+ //// pattern: string;
24
+ //// };
25
+ ////
26
+ ////declare let x: DocumentFilter;
27
+ ////x./**/language
28
+
29
+ verify . baselineQuickInfo ( ) ;
You can’t perform that action at this time.
0 commit comments