ES6 syntax allows to rename destructured variables and arguments.
Variables:
const {requestID: _requestID, notifyChanges: _notifyChanges} = someObject;
console.log(_requestID, _notifyChanges);
Arguments:
/**
* Creates a cloud ready request.
* @param {String} requestID Request ID used for for tracing and logs
* @param {Boolean} [notifyChanges] Send an event to the message queue.
*/
function createRequest({
requestID: _requestID,
notifyChanges: _notifyChanges = false,
}) {
console.log(_requestID, _notifyChanges);
});
Even though the JavaScript code above is valid, the JSDoc shows errors saying:
Parameter 'requestID' described in JSDoc does not appear in function signature
How would I properly annotate a descructured and renamed function argument in JSDoc?
Use colon in JSDoc parameter name:
/**
* Creates a cloud ready request.
* @param {String} _requestID:requestID Request ID used for for tracing and logs
* @param {Boolean} [_notifyChanges:notifyChanges] Send an event to the message queue.
*/
function createRequest({
requestID: _requestID,
notifyChanges: _notifyChanges = false,
}) {
console.log(_requestID, _notifyChanges);
});
This was tested in WebStorm IDE 2016.2. Works fine.