Webstorm is giving me an error:
TS2345: Argument of type (res: any) => Types of property 'type' are incompatible. Type '"CLOSE_ACTIVE_CHATS"' is not assignable to type '"DELETE_SELECTED_CHAT"'.
On my inner switchMap
switchMap((res) => {//error here
chat.mdRef.close();
if (chat.chat.state === 2) {
return [new CloseOpenChat(chat.chat._id), new
DeleteSelectedChat(),
new AddClosedChat(chat.chat)];
})
Full code
@Effect()
closeChat: Observable<any> = this.actions.pipe(
ofType(CLOSE_CHAT_CALL),
map((action: _Actions.AddClosedChat) => {
return action.payload;
}),
switchMap((chat: CloseChatI) => {
return this.messageService.closeChat(chat.chat._id).pipe(
// @ts-ignore
switchMap((res) => {
chat.mdRef.close();
if (chat.chat.state === 2) {
return [new CloseOpenChat(chat.chat._id), new
DeleteSelectedChat(),
new AddClosedChat(chat.chat)];
}
return [new CloseActiveChat(chat.chat._id), new
DeleteSelectedChat(),
new AddClosedChat(chat.chat)];
}),
catchError(ErrorService.handleError)
);
}),
catchError((err) => of(new CallFailed())
)
);