Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ngrx: Supplied parameters do not match any signature of call target

I am using ngrx/effects.

After updating rxjs from 5.0.0-beta.12 to 5.0.0-rc.1, my IDE WebStorm gives me the error below (red underline). And when I run my app, the same error also shows in the terminal.

Supplied parameters do not match any signature of call target.

enter image description here

  @Effect() updateProfile$ = this.actions$
    .ofType(ProfileActions.PROFILE_UPDATE_PROFILE)
    .map<string>(toPayload)
    .switchMap(name => this.profileService.updateProfile(name)
      .map(name => ({ type: ProfileActions.PROFILE_UPDATE_PROFILE_SUCCESS, payload: name }))
      .catch(error => Observable.of({ type: ProfileActions.PROFILE_UPDATE_PROFILE_FAIL, payload: error }))
    );

.

  updateProfile(name: string): Observable<string> {
    return Observable.of(name);
  }
  • This error happens whenever I use map<string>(toPayload). I tried to change to .map<any>(action => action.payload), but still same error.

  • The effects without map<string>(toPayload) won't give the error.

Although it gives me the error, the app still runs well.

How to solve this issue?

like image 846
Hongbo Miao Avatar asked Oct 16 '16 19:10

Hongbo Miao


1 Answers

In rxjs 5.0.0-rc.1 the generic type parameters for all operators were changed to accept the type of the source observable first.

You will need to change the map operator call accordingly:

actions$
  .ofType(ProfileActions.PROFILE_UPDATE_PROFILE)
  .map<Action, string>(toPayload)
like image 197
Mike R Avatar answered Nov 16 '22 01:11

Mike R