Skip to content

Commit 8e84ce1

Browse files
authored
🤖 Merge PR DefinitelyTyped#74565 [w3c-web-hid] Preserve event types when using EventListenerOptions by @noahm
1 parent f1d6804 commit 8e84ce1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

‎types/w3c-web-hid/index.d.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ declare class HID extends EventTarget {
2323
addEventListener(
2424
type: "connect" | "disconnect",
2525
listener: (this: this, ev: HIDConnectionEvent) => any,
26-
useCapture?: boolean,
26+
options?: boolean | AddEventListenerOptions,
2727
): void;
2828
addEventListener(
2929
type: string,
@@ -34,7 +34,7 @@ declare class HID extends EventTarget {
3434
removeEventListener(
3535
type: "connect" | "disconnect",
3636
callback: (this: this, ev: HIDConnectionEvent) => any,
37-
useCapture?: boolean,
37+
options?: boolean | AddEventListenerOptions,
3838
): void;
3939
removeEventListener(
4040
type: string,
@@ -156,14 +156,22 @@ declare class HIDDevice extends EventTarget {
156156

157157
receiveFeatureReport(reportId: number): Promise<DataView>;
158158

159-
addEventListener(type: "inputreport", listener: (this: this, ev: HIDInputReportEvent) => any): void;
159+
addEventListener(
160+
type: "inputreport",
161+
listener: (this: this, ev: HIDInputReportEvent) => any,
162+
options?: boolean | AddEventListenerOptions,
163+
): void;
160164
addEventListener(
161165
type: string,
162166
listener: EventListenerOrEventListenerObject | null,
163167
options?: boolean | AddEventListenerOptions,
164168
): void;
165169

166-
removeEventListener(type: "inputreport", callback: (this: this, ev: HIDInputReportEvent) => any): void;
170+
removeEventListener(
171+
type: "inputreport",
172+
callback: (this: this, ev: HIDInputReportEvent) => any,
173+
options?: boolean | AddEventListenerOptions,
174+
): void;
167175
removeEventListener(
168176
type: string,
169177
callback: EventListenerOrEventListenerObject | null,

‎types/w3c-web-hid/w3c-web-hid-tests.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async function example_1() {
1414

1515
navigator.hid.addEventListener("connect", ({ device }) => {
1616
console.log(`HID connected: ${device.productName}`);
17-
});
17+
}, { signal: AbortSignal.timeout(1000) });
1818

1919
navigator.hid.addEventListener("disconnect", ({ device }) => {
2020
console.log(`HID disconnected: ${device.productName}`);

0 commit comments

Comments
 (0)