-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improve JSDoc support for destructured parameters #1781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@shicks That looks ambiguous, I guess? What's the difference between /**
@param {number=} a
@param {number=} b
@param {number=} c
*/
function({a = 1, b = 2, c = 3} = {}) {} and /**
@param {number=} a
@param {number=} b
@param {number=} c
*/
function(a, b, c) {} ? |
I agree. I'd like to see the |
The
https://developers.google.com/closure/compiler/docs/js-for-compiler |
Our "JSDoc" parser requires every param to have a name, so for destructuring params, we allow any name that's a valid JS identifier, even though that name won't appear in the (non-comment) JS code. |
I agree with the original syntax request- converting to destructured parameters is a common refactoring operation when the number of optional parameters grows but the loss of per-parameter documentation is a clear regression. |
FYI JSDoc 3 provides following syntax: /**
* 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 }) {
// ...
}; ref: #2584 |
この書籍の主題ではないので、できるだけコンパクトな方法を採用 - microsoft/TypeScript#24045 - google/closure-compiler#1781 - microsoft/TypeScript#24746 fix #606
* fix(todo): JSDocのdestructuringの記法を修正 この書籍の主題ではないので、できるだけコンパクトな方法を採用 - microsoft/TypeScript#24045 - google/closure-compiler#1781 - microsoft/TypeScript#24746 fix #606 * fix(todo): removeEventListerを削除 TODOアプリのユースケースでは解除まで行っていないので削除する fix #607 * feat(todo): 残った課題を追加 * chore(todo): add comment * fix(todo): add <!-- doctest:disable -->
I think I'm having the same problem here… I'm converting a projects build chain to use Closure Compiler, and one of the sources in our application contains the following code which appears to be trying to use the official JSDoc syntax:
I tried converting this to the Closure doc syntax as mentioned above:
However when compiling this I get the following warning:
This appears to be down the the inclusion of the Is there an alternative way to document this, preferably so that I can keep the description of each parameter in the options object? |
Currently it is very cumbersome to use destructuring for function parameters with more than a couple properties, particular if many are optional:
Note that the
number=
syntax does not work, and in fact leads to #1762.Ideally we could write
The text was updated successfully, but these errors were encountered: