类型 'Observable<never>' 不可分配给类型 'never'
Type 'Observable<never>' is not assignable to type 'never'
如何修复这个错误
类型 'Observable' 不可分配给类型 'never'。
我在 angular 应用程序中使用 ngrx。
// 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>()
);
控制台错误:
通常一个效果必须return一个动作。如果你不想那样,你需要通过将 { dispatch: false }
作为第二个参数传递给 createEffect
.
来指定
如何修复这个错误 类型 'Observable' 不可分配给类型 'never'。
我在 angular 应用程序中使用 ngrx。
// 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>()
);
控制台错误:
通常一个效果必须return一个动作。如果你不想那样,你需要通过将 { dispatch: false }
作为第二个参数传递给 createEffect
.