2

How to fix an issue where argument of type (key:string) => Observable | PayloadType | is not assignable to parameter of type '(value: string, index: number) => ObersvableInput'

return action$.pipe(
    filter(a => a.type === 'ACTION'),
    mergeMap(action => {
        hideLoadingMask();
        return askForMessageDialog({
            title: 'test',
            type: 'question',
            text: getLocalized('test'),
            buttons: [
            { key: 'cancel', caption: 'cancel'},
            { key: 'notSave', caption: 'notSave' },
            { key: 'save', caption: 'save' }],
            primaryButtonKey: cancel
        }).pipe(
            mergeMap((key) => {
                switch (key) {
                    case notSave: {
                        return refresh();
                    }
                    case save: {
                        return saveChanges();
                    }
                    default: 
                        return empty();
                }
            })
        );
        
    })
);
  • Which line throws this error? Please give a complete example, remove irrelevant code. – Lin Du Oct 18 '21 at 04:29
  • Apologies if my question isn't clear. The line which throws an error is this one: `mergeMap((key) => ` Can it be because my action is of redux.ISimpleAction? – user2775418 Oct 18 '21 at 05:07

1 Answers1

1

I had to update the code into:

switch (key) {
                    case notSave: {
                        return of(refresh());
                    }
                    case save: {
                        return of(saveChanges());
                    }
                    default: 
                        return empty();
                }