2
ES6語法允許重命名解構變量和參數。使用JSDoc如何註解一個descructured重命名的函數參數?
變量:
const {requestID: _requestID, notifyChanges: _notifyChanges} = someObject;
console.log(_requestID, _notifyChanges);
參數:
/**
* 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);
});
即使上面的JavaScript代碼是有效的,JSDoc顯示錯誤說: Parameter 'requestID' described in JSDoc does not appear in function signature
我將如何正確地標註一個在JSDoc中描述並更名爲函數參數?