I have a TypeScript function that I need help with:
private async deleteSelectedLuminaires (): Promise<any[]> {
return this.dialogService.open({ viewModel: DeleteLuminaire, model: 'Cancel or Ok', lock: false })
.whenClosed((response) => {
if (!response.wasCancelled) {
const requests = this.selectedSerials
.map(async (serial) => this.luminaireApi.removeLuminaire({ serial }))
return Promise.all(requests)
}
})
}
The function this.luminaireApi.removeLuminaire returns Promise< void >. I am encountering an error when using the Dialog service to ask a question in this function. After deleting the dialog, I receive the following error message:
error TS2345: Argument of type '(response: DialogCloseResult) => Promise | undefined' is not assignable to parameter of type '(value: DialogCloseResult) => any[] | PromiseLike'. Type 'Promise | undefined' is not assignable to type 'any[] | PromiseLike'. Type 'undefined' is not assignable to type 'any[] | PromiseLike'.
I believe the issue lies in combining dialog and Promise.all, but I am unsure of the exact reason. Could someone please assist me in resolving this problem?