JSDoc comments for destructuring parameters not working in VSCode
Asked Answered
A

1

2

According to the doc, JSDoc supports destructuring parameters:

/**
 * Assign the project to an employee.
 * @param {Object} employee - The employee who is responsible for the project.
 * @param {string} employee.name - The name of the employee.
 * @param {string} employee.department - The employee's department.
 */
Project.prototype.assign = function({ name, department }) {
    // ...
};

However, it doesn't work for me in VSCode (v1.23.1). Has anyone successfully tried this?

VSCode and TypeScript repos contain several posts about similar issues, but they are confusing and closed (example here).

Aspirate answered 2/6, 2018 at 9:28 Comment(3)
"Doesn't work" how? If I paste that code into a file and put a constructor function declaration in front of it, then use const p = new Project();, typing p.assign( shows me the JSDoc for the employee parameter. (And I see that it's destructured, though I don't see the documentation for employee.name and .department.) Is that what you mean? (Interestingly: If you leave off the first @param above, what you see when you type p.assign( looks a lot like one would want...)Mckim
"though I don't see the documentation for employee.name and .department": that is one problem, the other one being that you cannot see the correct parameter types. This prevents automatic type checking from working correctly in many cases.Aspirate
The issue has been reported hereAspirate
A
3

This feature is supported from VSCode 1.24 only (TypeScript 2.9).

Situation as of now (VSCode 1.24.0):

  • Param type is parsed correctly, allowing for type checking.
  • Param description text doesn't show up in IntelliSense (issue reported here).
Aspirate answered 7/6, 2018 at 9:29 Comment(1)
Looking for clarification. Are you saying that JavaScript object destructing won't be supported [directly]? We will be forced to use TypeScript to appreciate that functionality? I'm on v1.42.1 and just found that the results where nothing like the JSDoc sample. All I got was /** * * @param {*} param0 */Faradize

© 2022 - 2024 — McMap. All rights reserved.