From 15bf00a0e998b580805fe8cdd6e5d20f5b6cfd73 Mon Sep 17 00:00:00 2001 From: "dominic.griesel" Date: Wed, 13 Feb 2019 12:25:43 +0100 Subject: [PATCH] Fix return types of the async versions --- types/iobroker/index.d.ts | 12 ++++++------ types/iobroker/iobroker-tests.ts | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index c385e4b050..1b0f26c4df 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -1477,7 +1477,7 @@ declare global { * @param options (optional) Some internal options. * @param callback Is called when the operation has finished (successfully or not) */ - getDevicesAsync(options?: unknown): Promise>>; + getDevicesAsync(options?: unknown): Promise; /** * Returns a list of all channels in this adapter instance @@ -1502,9 +1502,9 @@ declare global { * @param parentDevice (optional) Name of the parent device to filter the channels by * @param options (optional) Some internal options. */ - getChannelsOfAsync(): Promise>>; + getChannelsOfAsync(): Promise; // tslint:disable-next-line:unified-signatures - getChannelsOfAsync(parentDevice: string, options?: unknown): Promise>>; + getChannelsOfAsync(parentDevice: string, options?: unknown): Promise; /** * Returns a list of all states in this adapter instance @@ -1524,9 +1524,9 @@ declare global { * @param options (optional) Some internal options. */ // tslint:disable:unified-signatures - getStatesOfAsync(): Promise>>; - getStatesOfAsync(parentDevice: string, parentChannel?: string): Promise>>; - getStatesOfAsync(parentDevice: string, parentChannel: string, options?: unknown): Promise>>; + getStatesOfAsync(): Promise; + getStatesOfAsync(parentDevice: string, parentChannel?: string): Promise; + getStatesOfAsync(parentDevice: string, parentChannel: string, options?: unknown): Promise; // tslint:enable:unified-signatures // ============================== diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index 4d5afca348..0302a5041a 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -291,17 +291,26 @@ function repro2() { function repro3() { adapter.getDevices((error, deviceList) => { if (deviceList) { - deviceList[0]; // $ExpectType DeviceObject + deviceList; // $ExpectType DeviceObject[] } }); + adapter.getDevicesAsync().then(list => { + list; // $ExpectType DeviceObject[] + }); adapter.getChannels((error, channelList) => { if (channelList) { - channelList[0]; // $ExpectType ChannelObject + channelList; // $ExpectType ChannelObject[] } }); + adapter.getChannelsOfAsync().then(list => { + list; // $ExpectType ChannelObject[] + }); adapter.getStatesOf((error, stateList) => { if (stateList) { - stateList[0]; // $ExpectType StateObject + stateList; // $ExpectType StateObject[] } }); + adapter.getStatesOfAsync().then(list => { + list; // $ExpectType StateObject[] + }); }