File tree 5 files changed +252
-0
lines changed 5 files changed +252
-0
lines changed Original file line number Diff line number Diff line change @@ -575,6 +575,19 @@ namespace ts.SymbolDisplay {
575
575
}
576
576
}
577
577
578
+ if ( documentation . length === 0 && isIdentifier ( location ) && symbol . valueDeclaration && isBindingElement ( symbol . valueDeclaration ) ) {
579
+ const declaration = symbol . valueDeclaration ;
580
+ const parent = declaration . parent ;
581
+ if ( isIdentifier ( declaration . name ) && isObjectBindingPattern ( parent ) ) {
582
+ const name = getTextOfIdentifierOrLiteral ( declaration . name ) ;
583
+ const type = typeChecker . getTypeAtLocation ( parent ) ;
584
+ const prop = firstDefined ( type . isUnion ( ) ? type . types : [ type ] , t => t . getProperty ( name ) ) ;
585
+ if ( prop ) {
586
+ documentation = prop . getDocumentationComment ( typeChecker ) ;
587
+ }
588
+ }
589
+ }
590
+
578
591
if ( tags . length === 0 && ! hasMultipleSignatures ) {
579
592
tags = symbol . getJsDocTags ( typeChecker ) ;
580
593
}
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "marker": {
4
+ "fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName03.ts",
5
+ "position": 122,
6
+ "name": "1"
7
+ },
8
+ "quickInfo": {
9
+ "kind": "parameter",
10
+ "kindModifiers": "",
11
+ "textSpan": {
12
+ "start": 119,
13
+ "length": 3
14
+ },
15
+ "displayParts": [
16
+ {
17
+ "text": "(",
18
+ "kind": "punctuation"
19
+ },
20
+ {
21
+ "text": "parameter",
22
+ "kind": "text"
23
+ },
24
+ {
25
+ "text": ")",
26
+ "kind": "punctuation"
27
+ },
28
+ {
29
+ "text": " ",
30
+ "kind": "space"
31
+ },
32
+ {
33
+ "text": "foo",
34
+ "kind": "parameterName"
35
+ },
36
+ {
37
+ "text": ":",
38
+ "kind": "punctuation"
39
+ },
40
+ {
41
+ "text": " ",
42
+ "kind": "space"
43
+ },
44
+ {
45
+ "text": "string",
46
+ "kind": "keyword"
47
+ }
48
+ ],
49
+ "documentation": [
50
+ {
51
+ "text": "A description of foo",
52
+ "kind": "text"
53
+ }
54
+ ]
55
+ }
56
+ }
57
+ ]
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "marker": {
4
+ "fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts",
5
+ "position": 193,
6
+ "name": "1"
7
+ },
8
+ "quickInfo": {
9
+ "kind": "parameter",
10
+ "kindModifiers": "",
11
+ "textSpan": {
12
+ "start": 192,
13
+ "length": 1
14
+ },
15
+ "displayParts": [
16
+ {
17
+ "text": "(",
18
+ "kind": "punctuation"
19
+ },
20
+ {
21
+ "text": "parameter",
22
+ "kind": "text"
23
+ },
24
+ {
25
+ "text": ")",
26
+ "kind": "punctuation"
27
+ },
28
+ {
29
+ "text": " ",
30
+ "kind": "space"
31
+ },
32
+ {
33
+ "text": "a",
34
+ "kind": "parameterName"
35
+ },
36
+ {
37
+ "text": ":",
38
+ "kind": "punctuation"
39
+ },
40
+ {
41
+ "text": " ",
42
+ "kind": "space"
43
+ },
44
+ {
45
+ "text": "{",
46
+ "kind": "punctuation"
47
+ },
48
+ {
49
+ "text": "\n",
50
+ "kind": "lineBreak"
51
+ },
52
+ {
53
+ "text": " ",
54
+ "kind": "space"
55
+ },
56
+ {
57
+ "text": "b",
58
+ "kind": "propertyName"
59
+ },
60
+ {
61
+ "text": ":",
62
+ "kind": "punctuation"
63
+ },
64
+ {
65
+ "text": " ",
66
+ "kind": "space"
67
+ },
68
+ {
69
+ "text": "string",
70
+ "kind": "keyword"
71
+ },
72
+ {
73
+ "text": ";",
74
+ "kind": "punctuation"
75
+ },
76
+ {
77
+ "text": "\n",
78
+ "kind": "lineBreak"
79
+ },
80
+ {
81
+ "text": "}",
82
+ "kind": "punctuation"
83
+ }
84
+ ],
85
+ "documentation": [
86
+ {
87
+ "text": "A description of 'a'",
88
+ "kind": "text"
89
+ }
90
+ ]
91
+ }
92
+ },
93
+ {
94
+ "marker": {
95
+ "fileName": "/tests/cases/fourslash/quickInfoForObjectBindingElementName04.ts",
96
+ "position": 200,
97
+ "name": "2"
98
+ },
99
+ "quickInfo": {
100
+ "kind": "parameter",
101
+ "kindModifiers": "",
102
+ "textSpan": {
103
+ "start": 199,
104
+ "length": 1
105
+ },
106
+ "displayParts": [
107
+ {
108
+ "text": "(",
109
+ "kind": "punctuation"
110
+ },
111
+ {
112
+ "text": "parameter",
113
+ "kind": "text"
114
+ },
115
+ {
116
+ "text": ")",
117
+ "kind": "punctuation"
118
+ },
119
+ {
120
+ "text": " ",
121
+ "kind": "space"
122
+ },
123
+ {
124
+ "text": "b",
125
+ "kind": "parameterName"
126
+ },
127
+ {
128
+ "text": ":",
129
+ "kind": "punctuation"
130
+ },
131
+ {
132
+ "text": " ",
133
+ "kind": "space"
134
+ },
135
+ {
136
+ "text": "string",
137
+ "kind": "keyword"
138
+ }
139
+ ],
140
+ "documentation": [
141
+ {
142
+ "text": "A description of 'b'",
143
+ "kind": "text"
144
+ }
145
+ ]
146
+ }
147
+ }
148
+ ]
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ ////interface Options {
4
+ //// /**
5
+ //// * A description of foo
6
+ //// */
7
+ //// foo: string;
8
+ //// }
9
+ ////
10
+ ////function f({ foo }: Options) {
11
+ //// foo/*1*/;
12
+ //// }
13
+
14
+ verify . baselineQuickInfo ( ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path="fourslash.ts" />
2
+
3
+ ////interface Options {
4
+ //// /**
5
+ //// * A description of 'a'
6
+ //// */
7
+ //// a: {
8
+ //// /**
9
+ //// * A description of 'b'
10
+ //// */
11
+ //// b: string;
12
+ //// }
13
+ //// }
14
+ ////
15
+ ////function f({ a, a: { b } }: Options) {
16
+ //// a/*1*/;
17
+ //// b/*2*/;
18
+ //// }
19
+
20
+ verify . baselineQuickInfo ( ) ;
You can’t perform that action at this time.
0 commit comments