Fix return types of the async versions

This commit is contained in:
dominic.griesel
2019-02-13 12:25:43 +01:00
parent 6173cb1bd3
commit 15bf00a0e9
2 changed files with 18 additions and 9 deletions
+6 -6
View File
@@ -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<Array<GetObjectsItem<DeviceObject>>>;
getDevicesAsync(options?: unknown): Promise<DeviceObject[]>;
/**
* 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<Array<GetObjectsItem<ChannelObject>>>;
getChannelsOfAsync(): Promise<ChannelObject[]>;
// tslint:disable-next-line:unified-signatures
getChannelsOfAsync(parentDevice: string, options?: unknown): Promise<Array<GetObjectsItem<ChannelObject>>>;
getChannelsOfAsync(parentDevice: string, options?: unknown): Promise<ChannelObject[]>;
/**
* 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<Array<GetObjectsItem<StateObject>>>;
getStatesOfAsync(parentDevice: string, parentChannel?: string): Promise<Array<GetObjectsItem<StateObject>>>;
getStatesOfAsync(parentDevice: string, parentChannel: string, options?: unknown): Promise<Array<GetObjectsItem<StateObject>>>;
getStatesOfAsync(): Promise<StateObject[]>;
getStatesOfAsync(parentDevice: string, parentChannel?: string): Promise<StateObject[]>;
getStatesOfAsync(parentDevice: string, parentChannel: string, options?: unknown): Promise<StateObject[]>;
// tslint:enable:unified-signatures
// ==============================
+12 -3
View File
@@ -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[]
});
}