Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Improve `AddEventListenerOptions` docs

未关闭
#2,135 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
38/100
Issue 类型
文档
描述清晰度
基本清楚
活跃度
停滞
技术栈
typescript

调研方向

定位 AddEventListenerOptions 接口的生成器输入和输出,然后对比附近有文档的接口,以了解注释如何传播到生成的声明中。通过项目已确立的源添加所提供的文档,并验证生成的输出包含该文档且相关检查均通过。

由索引模型根据 Issue 内容生成。

描述

I spent 10 minutes and couldn't figure out how to add these docs to the generated output, so here's a recommended declaration from the Deno repo:

/**
 * Specifies characteristics about the event listener or the event handler it can invoke.
 *
 * This interface extends `EventListenerOptions` and provides additional configuration
 * options for controlling event listener behavior.
 *
 * @example
 * ```ts
 * target.addEventListener('message', handler, {
 *   once: true,
 *   passive: true,
 *   signal: controller.signal
 * });
 * ```
 */
/**
 * Options that can be specified when adding an event listener via `addEventListener`.
 *
 * This interface extends `EventListenerOptions` and provides additional configuration
 * options for controlling event listener behavior in a worker context.
 *
 * @example
 * ```ts
 * // Register a message event handler that automatically removes itself after one invocation
 * worker.addEventListener('message', handleMessageOnce, { once: true });
 *
 * // Register a message event handler that doesn't block the runtime while processing events
 * worker.addEventListener('message', handleMessage, { passive: true });
 *
 * // Register a message event handler that can be removed via an AbortController
 * const controller = new AbortController();
 * worker.addEventListener('message', handleMessage, { signal: controller.signal });
 *
 * // Later, to remove the listener:
 * controller.abort();
 * ```
 */
interface AddEventListenerOptions extends EventListenerOptions {
    /**
     * When set to true, the listener will be automatically removed after being invoked once.
     * If not specified, defaults to false.
     */
    once?: boolean;

    /**
     * When set to true, indicates that the function specified by the listener will never call
     * `preventDefault()`. This allows optimization of the processing of events.
     * If a passive listener does try to call `preventDefault()`, it will be ignored.
     */
    passive?: boolean;

    /**
     * An `AbortSignal` that can be used to remove the event listener by calling `abort()`
     * on the controller that created the signal.
     *
     * @example
     * ```ts
     * const controller = new AbortController();
     * target.addEventListener('mousemove', handler, { signal: controller.signal });
     *
     * // Later, to remove the listener:
     * controller.abort();
     * ```
     */
    signal?: AbortSignal;
}

I can contribute it if someone points out how to add this or feel free to go ahead and add it.

主要语言
TypeScript
星标
740
派生
474
平均合并
3 天 7 小时
30 天内合并 PR
14

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/TypeScript-DOM-lib-generator 的其他 Issue

查看 microsoft/TypeScript-DOM-lib-generator 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。