Skip to content

JSDoc comments are ignored for destructured parameters #22980

@ryansully

Description

@ryansully

According to jsdoc/jsdoc#987 (comment), JSDoc for destructured function parameters should be possible:

/**
 * My cool function.
 *
 * @param {Object} obj - An object.
 * @param {string} obj.prop1 - Property 1.
 * @param {string} obj.prop2 - Property 2.
 */
var fn = function ({prop1, prop2}) {
  // Do something with prop1 and prop2
}

However, when invoking the function, while Intellisense appears to support properties inside the object param, there is no documentation for individual params inside the destructured object, and the property types are not honored (shown as any instead):
jsdoc-destructuring

If I set parameter defaults, Intellisense will support those, but will still ignore the types specified in the doc comment (notice that the JSDoc comment is not consistent with the function definition):
jsdoc-destructuring-defaults

And in both cases, the entire object param is highlighted, but individual params inside it are not.

Is there a different way to write the JSDoc comment, or does support for destructured parameters need to be supported by VS Code as well?

Metadata

Metadata

Assignees

Labels

javascriptJavaScript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions