【发布时间】:2019-02-01 14:52:42
【问题描述】:
我使用 Angular 7.1.4
我的效果:
@Injectable()
export class LoginEffects {
constructor(private actions$: Actions, private authService: AuthenticationService) {
}
@Effect({dispatch: true})
loginRequest$: Observable<any> = this.actions$.pipe(
ofType(LoginActionsType.LOGIN_REQUEST),
exhaustMap(payload => { // it might be switchMap, the error is the same.
console.log(payload);
return this.authService.login(payload.user, payload.password) // TypeScript Errors: Property 'user' does not exist on type 'never'. ; TS2339: Property 'password' does not exist on type 'never'.
.pipe(
map(user => new LoginSuccessAction(user)),
catchError( err => of(new LogOutAction(err)))
);
})
);
}
我得到这个错误:错误错误:效果“LoginEffects.loginRequest$”调度了一个无效的动作:...
如果我在 @Effect 装饰器中添加 {dispatch: false},错误就消失了。
如果尝试访问有效负载属性,我也会收到打字稿错误。
【问题讨论】:
标签: javascript angular typescript ngrx ngrx-effects