Skip to content

Commit 79736ef

Browse files
authored
fix(55258): JSDoc render with @param Object properties (#55264)
1 parent 1f88596 commit 79736ef

File tree

3 files changed

+210
-0
lines changed

3 files changed

+210
-0
lines changed

src/services/jsDoc.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ import {
4444
isIdentifier,
4545
isJSDoc,
4646
isJSDocParameterTag,
47+
isJSDocPropertyLikeTag,
48+
isJSDocTypeLiteral,
4749
isWhiteSpaceSingleLine,
4850
JSDoc,
4951
JSDocAugmentsTag,
@@ -250,6 +252,12 @@ export function getJsDocTagsFromDeclarations(declarations?: Declaration[], check
250252
}
251253
for (const tag of tags) {
252254
infos.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) });
255+
256+
if (isJSDocPropertyLikeTag(tag) && tag.isNameFirst && tag.typeExpression && isJSDocTypeLiteral(tag.typeExpression.type)) {
257+
forEach(tag.typeExpression.type.jsDocPropertyTags, propTag => {
258+
infos.push({ name: propTag.tagName.text, text: getCommentDisplayParts(propTag, checker) });
259+
});
260+
}
253261
}
254262
});
255263
return infos;
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
=== /tests/cases/fourslash/quickInfoJsDocTags12.ts ===
2+
// /**
3+
// * @param {Object} options the args object
4+
// * @param {number} options.a first number
5+
// * @param {number} options.b second number
6+
// * @param {Function} callback the callback function
7+
// * @returns {number}
8+
// */
9+
// function f(options, callback = null) {
10+
// ^
11+
// | ----------------------------------------------------------------------
12+
// | function f(options: any, callback?: any): void
13+
// | @param options the args object
14+
// | @param options.a first number
15+
// | @param options.b second number
16+
// | @param callback the callback function
17+
// | @returns
18+
// | ----------------------------------------------------------------------
19+
// }
20+
21+
[
22+
{
23+
"marker": {
24+
"fileName": "/tests/cases/fourslash/quickInfoJsDocTags12.ts",
25+
"position": 218,
26+
"name": ""
27+
},
28+
"item": {
29+
"kind": "function",
30+
"kindModifiers": "",
31+
"textSpan": {
32+
"start": 218,
33+
"length": 1
34+
},
35+
"displayParts": [
36+
{
37+
"text": "function",
38+
"kind": "keyword"
39+
},
40+
{
41+
"text": " ",
42+
"kind": "space"
43+
},
44+
{
45+
"text": "f",
46+
"kind": "functionName"
47+
},
48+
{
49+
"text": "(",
50+
"kind": "punctuation"
51+
},
52+
{
53+
"text": "options",
54+
"kind": "parameterName"
55+
},
56+
{
57+
"text": ":",
58+
"kind": "punctuation"
59+
},
60+
{
61+
"text": " ",
62+
"kind": "space"
63+
},
64+
{
65+
"text": "any",
66+
"kind": "keyword"
67+
},
68+
{
69+
"text": ",",
70+
"kind": "punctuation"
71+
},
72+
{
73+
"text": " ",
74+
"kind": "space"
75+
},
76+
{
77+
"text": "callback",
78+
"kind": "parameterName"
79+
},
80+
{
81+
"text": "?",
82+
"kind": "punctuation"
83+
},
84+
{
85+
"text": ":",
86+
"kind": "punctuation"
87+
},
88+
{
89+
"text": " ",
90+
"kind": "space"
91+
},
92+
{
93+
"text": "any",
94+
"kind": "keyword"
95+
},
96+
{
97+
"text": ")",
98+
"kind": "punctuation"
99+
},
100+
{
101+
"text": ":",
102+
"kind": "punctuation"
103+
},
104+
{
105+
"text": " ",
106+
"kind": "space"
107+
},
108+
{
109+
"text": "void",
110+
"kind": "keyword"
111+
}
112+
],
113+
"documentation": [],
114+
"tags": [
115+
{
116+
"name": "param",
117+
"text": [
118+
{
119+
"text": "options",
120+
"kind": "parameterName"
121+
},
122+
{
123+
"text": " ",
124+
"kind": "space"
125+
},
126+
{
127+
"text": "the args object",
128+
"kind": "text"
129+
}
130+
]
131+
},
132+
{
133+
"name": "param",
134+
"text": [
135+
{
136+
"text": "options.a",
137+
"kind": "parameterName"
138+
},
139+
{
140+
"text": " ",
141+
"kind": "space"
142+
},
143+
{
144+
"text": "first number",
145+
"kind": "text"
146+
}
147+
]
148+
},
149+
{
150+
"name": "param",
151+
"text": [
152+
{
153+
"text": "options.b",
154+
"kind": "parameterName"
155+
},
156+
{
157+
"text": " ",
158+
"kind": "space"
159+
},
160+
{
161+
"text": "second number",
162+
"kind": "text"
163+
}
164+
]
165+
},
166+
{
167+
"name": "param",
168+
"text": [
169+
{
170+
"text": "callback",
171+
"kind": "parameterName"
172+
},
173+
{
174+
"text": " ",
175+
"kind": "space"
176+
},
177+
{
178+
"text": "the callback function",
179+
"kind": "text"
180+
}
181+
]
182+
},
183+
{
184+
"name": "returns"
185+
}
186+
]
187+
}
188+
}
189+
]
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
/////**
4+
//// * @param {Object} options the args object
5+
//// * @param {number} options.a first number
6+
//// * @param {number} options.b second number
7+
//// * @param {Function} callback the callback function
8+
//// * @returns {number}
9+
//// */
10+
////function /**/f(options, callback = null) {
11+
////}
12+
13+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)