javascript - 如果一些被解构而另一些没有被解构,如何记录函数的参数(JSDoc)
问题描述
How to document deconstructed parameters with JsDoc解释了如果只有一个正在被解构的参数,如何记录参数。
我有这个class
来创建自定义事件:
const EVENT_CONFIG_DEFAULTS = Object.freeze({
bubbles: true,
composed: true,
});
/**
* class for all FW custom events
*/
export class FWEvent extends CustomEvent {
#sourceEvent = null;
#sourceElement = null;
/**
*
* @param {string} name name of the event, see fw-events.js
* @param {EventInit} eventInit event configuration
* @param {Event} [sourceEvent] optional source event
* @param {HTMLElement} [sourceElement] optional source element to circumvent event retargeting
*/
constructor(name, eventInit, { sourceEvent, sourceElement }) {
super(name, { ...EVENT_CONFIG_DEFAULTS, ...eventInit });
this.#sourceEvent = sourceEvent || null;
this.#sourceElement = sourceElement || null;
}
get sourceEvent() {
return this.#sourceEvent;
}
get sourceElement() {
return this.#sourceElement;
}
}
所以我有一个可选的第三个参数,由于解构的限制,我无法命名。
我如何正确记录这一点?显示的 JSDoc 显然是不正确的。
解决方案
推荐阅读
- java - Java Scanner 的 nextLine() 方法没有找到任何行
- sql-server - 为什么在此 SQL 2008 查询中连接 varchar 时会有空格?
- shopify - Shopify 购物车 Webhook - 额外数据
- django-rest-framework - 为什么我无法在项目目录上创建虚拟环境?
- php - RewriteEngine On 不工作但重定向工作
- python - 要在列表中列出的 Python 字符串
- javascript - 身份验证失败,原因是:缺少自定义请求令牌 cookie
- reactjs - React-Final-Form 如何将道具 location.search 传递给函数
- ios - 从库中挑选的视频未在 iOS 13 中播放
- oracle - 使用 DBMS_CRYPTO 函数解密 CLOB 数据时出错