mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
fix(55258): JSDoc render with @param Object properties (#55264)
This commit is contained in:
parent
1f88596bb1
commit
79736eff89
@ -44,6 +44,8 @@ import {
|
||||
isIdentifier,
|
||||
isJSDoc,
|
||||
isJSDocParameterTag,
|
||||
isJSDocPropertyLikeTag,
|
||||
isJSDocTypeLiteral,
|
||||
isWhiteSpaceSingleLine,
|
||||
JSDoc,
|
||||
JSDocAugmentsTag,
|
||||
@ -250,6 +252,12 @@ export function getJsDocTagsFromDeclarations(declarations?: Declaration[], check
|
||||
}
|
||||
for (const tag of tags) {
|
||||
infos.push({ name: tag.tagName.text, text: getCommentDisplayParts(tag, checker) });
|
||||
|
||||
if (isJSDocPropertyLikeTag(tag) && tag.isNameFirst && tag.typeExpression && isJSDocTypeLiteral(tag.typeExpression.type)) {
|
||||
forEach(tag.typeExpression.type.jsDocPropertyTags, propTag => {
|
||||
infos.push({ name: propTag.tagName.text, text: getCommentDisplayParts(propTag, checker) });
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
return infos;
|
||||
|
||||
189
tests/baselines/reference/quickInfoJsDocTags12.baseline
Normal file
189
tests/baselines/reference/quickInfoJsDocTags12.baseline
Normal file
@ -0,0 +1,189 @@
|
||||
=== /tests/cases/fourslash/quickInfoJsDocTags12.ts ===
|
||||
// /**
|
||||
// * @param {Object} options the args object
|
||||
// * @param {number} options.a first number
|
||||
// * @param {number} options.b second number
|
||||
// * @param {Function} callback the callback function
|
||||
// * @returns {number}
|
||||
// */
|
||||
// function f(options, callback = null) {
|
||||
// ^
|
||||
// | ----------------------------------------------------------------------
|
||||
// | function f(options: any, callback?: any): void
|
||||
// | @param options the args object
|
||||
// | @param options.a first number
|
||||
// | @param options.b second number
|
||||
// | @param callback the callback function
|
||||
// | @returns
|
||||
// | ----------------------------------------------------------------------
|
||||
// }
|
||||
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoJsDocTags12.ts",
|
||||
"position": 218,
|
||||
"name": ""
|
||||
},
|
||||
"item": {
|
||||
"kind": "function",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 218,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "function",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "f",
|
||||
"kind": "functionName"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "options",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ",",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "callback",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": "?",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "any",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"documentation": [],
|
||||
"tags": [
|
||||
{
|
||||
"name": "param",
|
||||
"text": [
|
||||
{
|
||||
"text": "options",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "the args object",
|
||||
"kind": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "param",
|
||||
"text": [
|
||||
{
|
||||
"text": "options.a",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "first number",
|
||||
"kind": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "param",
|
||||
"text": [
|
||||
{
|
||||
"text": "options.b",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "second number",
|
||||
"kind": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "param",
|
||||
"text": [
|
||||
{
|
||||
"text": "callback",
|
||||
"kind": "parameterName"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "the callback function",
|
||||
"kind": "text"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "returns"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
13
tests/cases/fourslash/quickInfoJsDocTags12.ts
Normal file
13
tests/cases/fourslash/quickInfoJsDocTags12.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
/////**
|
||||
//// * @param {Object} options the args object
|
||||
//// * @param {number} options.a first number
|
||||
//// * @param {number} options.b second number
|
||||
//// * @param {Function} callback the callback function
|
||||
//// * @returns {number}
|
||||
//// */
|
||||
////function /**/f(options, callback = null) {
|
||||
////}
|
||||
|
||||
verify.baselineQuickInfo();
|
||||
Loading…
x
Reference in New Issue
Block a user