TypeScript: JSDoc comment for destructuring param: description text not displayed
TypeScript Version:
2.9
Search Terms:
JSDoc destructuring param
Code
/**
* @param {Object} arg
* @param {number} arg.id - This param description won't show up
*/
function foo({ id }) {}
Expected behavior:
In VSCode 1.24.0, when typing foo(, IntelliSense should display the full param description, including its type and text.
Actual behavior:
The type is displayed (“number”), but not the text (“This param description won’t show up”):

Related Issues: https://github.com/Microsoft/TypeScript/issues/19645
Additional remark
When omitting the {Object} line, the param text shows up correctly:

About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 29
- Comments: 25 (2 by maintainers)
Commits related to this issue
- fix(todo): JSDocのdestructuringの記法を修正 この書籍の主題ではないので、できるだけコンパクトな方法を採用 - https://github.com/Microsoft/TypeScript/issues/24045 - https://github.com/google/closure-compiler/issues/1781 - https://github.c... — committed to asciidwango/js-primer by azu 6 years ago
- feat(todo): Todoアプリの課題を追加 (#620) * fix(todo): JSDocのdestructuringの記法を修正 この書籍の主題ではないので、できるだけコンパクトな方法を採用 - https://github.com/Microsoft/TypeScript/issues/24045 - https://github.com/google/closur... — committed to asciidwango/js-primer by azu 6 years ago
@THoisington, for that to work, you need to first define a custom object for the options, and then define its properties. Then you assign that custom type as your parameter:
That’ll give you IntelliSense for each property on the options parameter.
Is JSDoc dead? This is not solved after more than 4 years.
I’m having the same issue, I’m currently using javascript, and the solution provided by @lookuh partially implemented works in an awkward way.
When used the JSDocs comments in this way, it for sure won’t show the destructured params comments:
But when at least one of the param is defined as property, it starts to show the other params comments correctly, but it does not give type to them:
And a full typedef with @property solution isn’t showing the destructured params:
Hope this comment helps in any way.
That’s because TypeScript treats JSDoc types
objectandObjectasany. You can designate a generic object usingObject.<string, any>. So, redoing the above will give you the proper intellisense forid:Bumping up this. It’s a major issue. Destructured parameters have been around since ES6, and JSDoc has an official documentation on how to document them properly. They’re used everywhere, why was it never properly supported in VSCode’s JSDoc tooltips?
This is still an issue. The official jsdoc gives this example
Found here https://jsdoc.app/tags-param.html#parameters-with-properties subheader - Documenting a destructuring parameter
I’d expect the tooltip to work if the jsdoc is correct per its own documentation
I have found the simplest cleanest solution for this mess.
@Juanpam The problem here is that we lose the type definition of the arguments at the top. We can’t have both at the same time.
Interestingly, both the typedef and the integrated properties syntax work if you declare the argument you’re destructuring to be a
@propertyinstead of the@paramthat it is.You are missing the empty line I added with the @property part.
@J3m5 I agree! Just my workaround for this issue. Still hoping this gets reviewed soon.