diff --git a/types/web-bluetooth/index.d.ts b/types/web-bluetooth/index.d.ts index 912a7fdd55..d2f92309ed 100644 --- a/types/web-bluetooth/index.d.ts +++ b/types/web-bluetooth/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Web Bluetooth // Project: https://webbluetoothcg.github.io/web-bluetooth/ // Definitions by: Uri Shaked +// Xavier Lozinguez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped type BluetoothServiceUUID = number | string; @@ -15,11 +16,13 @@ interface BluetoothRequestDeviceFilter { serviceDataUUID?: BluetoothServiceUUID; } -interface RequestDeviceOptions { +type RequestDeviceOptions = { filters: BluetoothRequestDeviceFilter[]; optionalServices?: BluetoothServiceUUID[]; - acceptAllDevices?: boolean; -} +} | { + acceptAllDevices: boolean; + optionalServices?: BluetoothServiceUUID[]; +}; interface BluetoothRemoteGATTDescriptor { readonly characteristic: BluetoothRemoteGATTCharacteristic; @@ -98,11 +101,9 @@ interface BluetoothDevice extends EventTarget, BluetoothDeviceEventHandlers, Cha readonly name?: string; readonly gatt?: BluetoothRemoteGATTServer; readonly uuids?: string[]; - watchAdvertisements(): Promise; unwatchAdvertisements(): void; readonly watchingAdvertisements: boolean; - addEventListener(type: "gattserverdisconnected", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: "advertisementreceived", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -113,7 +114,6 @@ interface Bluetooth extends EventTarget, BluetoothDeviceEventHandlers, Character onavailabilitychanged: (this: this, ev: Event) => any; readonly referringDevice?: BluetoothDevice; requestDevice(options?: RequestDeviceOptions): Promise; - addEventListener(type: "availabilitychanged", listener: (this: this, ev: Event) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; }