docblockr
docblockr copied to clipboard
JavaScript destructuring
Hi everyone!
I thought recognizing destructuring in function params could be a good enhancement! This is the actual result when it is used:
/**
* [handleRecaptchaErrors description]
* @param {[type]} res [description]
* @param {[type]} { status [description]
* @param {[type]} statusText [description]
* @param {[type]} config } [description]
* @return {[type]} [description]
*/
export function handleRecaptchaErrors(res, { status, statusText, config }) {
// Code here
}
Getting something similar to this could be convenient:
/**
* Handles the errors that can occur when requesting the reCatpcha API
* @param {Object} res [HTTP response of the /contactMe resource]
* @param {Object} recaptchaRequestResponse [Axios response received requesting the reCaptcha API]
* @property {Number} status [Status code]
* @property {String} statusText [Status message]
* @property {Object} config [Original axios request config]
*/
export function handleRecaptchaErrors(res, { status, statusText, config }) {
// Code here
}
That being said, I'm really not comfortable with RegExp (...I should start learning) so not sure I can implement this myself
Hey there!
Same goes when you use ES6 Spread Operator as function parameter:
/**
* [example description]
* @param {[type]} prop [description]
* @param {[type]} ...props [description]
* @return {[type]} [description]
*/
function example (prop, ...props) {
// Code here
}
I do not have a good idea how to handle Spread Operator parameters. Maybe just defining their type to be Array
:thought_balloon:
@dirchev could you please open a new issue for adding support for the spread operator.
This should be addressed with some prio cause it's causing exceptions (See #219 and #197).
I do not have a good idea how to handle Spread Operator parameters. Maybe just defining their type to be
Array
The coder may want to make it Array<{type}>
so maybe that should be the placeholder.
+1 on this issue
With docblockr 0.13.7 and atom 1.31.2, the package correctly handles
function foo(x, {a, b}) { /* etc */ }
// results in
/**
* [foo description]
* @param {[type]} x [description]
* @param {[type]} a [description]
* @param {[type]} b [description]
* @return {[type]} [description]
*/
but
function bar(x, {a, b} = {a: 1, b: "2"}) {/* etc */}
// results in
/**
* [foo description]
* @param {[type]} x [description]
* @param {[type]} a [description]
* @param {[type]} b [description]
* @param {[type]} b [description]
* @return {[type]} [description]
*/
No errors or docblockr-related warnings are written to the console.