Argument of type is not assignable to type ObservableInput<any>

1.5k Views Asked by At

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();
                }
            })
        );
        
    })
);
1

There are 1 best solutions below

1
user2775418 On

I had to update the code into:

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