Home > Blockchain >  Type 'Observable<never>' is not assignable to type 'never'
Type 'Observable<never>' is not assignable to type 'never'

Time:10-02

How to fix this error Type 'Observable' is not assignable to type 'never'.

I use ngrx in my angular app.

// auth.effects.ts

effectLogInSuccess$ = createEffect(() =>
    this.actions$.pipe(
      ofType(AuthActionTypes.LOGIN_SUCCESS),
      tap((user) => {
        localStorage.setItem('token', user.payload.token);
        this.router.navigateByUrl('/');
      })
    ));

// auth.actions.ts

export const actionLogInSuccess = createAction(
  AuthActionTypes.LOGIN_SUCCESS,
  props<any>()
);

Error in console: enter image description here

CodePudding user response:

Normally an effect has to return an action. If you do not want that, you need to specifiy that by passing { dispatch: false } as second parameter to createEffect.

See docs: https://ngrx.io/api/effects/createEffect

  • Related