From 2e0f25538ed4245530231e0a71396ac9f957033b Mon Sep 17 00:00:00 2001 From: Xavier Lozinguez Date: Tue, 12 Dec 2017 17:38:54 -0500 Subject: [PATCH 1/2] Fixed web-bluetooth types as filters are optionals --- types/web-bluetooth/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/web-bluetooth/index.d.ts b/types/web-bluetooth/index.d.ts index 912a7fdd55..ea01176c38 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; @@ -16,7 +17,7 @@ interface BluetoothRequestDeviceFilter { } interface RequestDeviceOptions { - filters: BluetoothRequestDeviceFilter[]; + filters?: BluetoothRequestDeviceFilter[]; optionalServices?: BluetoothServiceUUID[]; acceptAllDevices?: boolean; } From 07968972fea72f30f66a021f006d39dd0d472ae9 Mon Sep 17 00:00:00 2001 From: Xavier Lozinguez Date: Thu, 14 Dec 2017 18:14:36 -0500 Subject: [PATCH 2/2] Adjusted RequestedDeviceOptions type definition to indicate that either `filters` or `acceptAllDevices` should be specified. --- types/web-bluetooth/index.d.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/types/web-bluetooth/index.d.ts b/types/web-bluetooth/index.d.ts index ea01176c38..d2f92309ed 100644 --- a/types/web-bluetooth/index.d.ts +++ b/types/web-bluetooth/index.d.ts @@ -16,11 +16,13 @@ interface BluetoothRequestDeviceFilter { serviceDataUUID?: BluetoothServiceUUID; } -interface RequestDeviceOptions { - filters?: BluetoothRequestDeviceFilter[]; +type RequestDeviceOptions = { + filters: BluetoothRequestDeviceFilter[]; optionalServices?: BluetoothServiceUUID[]; - acceptAllDevices?: boolean; -} +} | { + acceptAllDevices: boolean; + optionalServices?: BluetoothServiceUUID[]; +}; interface BluetoothRemoteGATTDescriptor { readonly characteristic: BluetoothRemoteGATTCharacteristic; @@ -99,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; @@ -114,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; }