【发布时间】:2019-07-10 07:58:57
【问题描述】:
我正在使用 Angular 8 和 NGRX 8。我有一个动作:
export const loadEnvironment = createAction(
LicencingActionTypes.LoadEnvironment,
props<{environment: Environment}>()
);
及对应效果:
loadEnvironment = createEffect(() => this.actions$.pipe(
ofType(LicencingActionTypes.LoadEnvironment),
exhaustMap((action) =>
this.authService.
getToken(LicencingEffects.getAuthDetailsForEnvironment(action.environment))
.pipe(
switchMap((token) => [
AuthActions.onLogin({token: token}),
LicencingActions.onLoadEnvironment({environment: action.environment})
]),
catchError(error => of(AuthActions.onLoginError({error: error})))
)
)
));
我一直在阅读有关 NGRX 8 (https://ngrx.io/guide/effects#incorporating-state) 的文档。
他们的例子表明你可以只使用 action 属性而不需要转换动作的类型:
...
exhaustMap(action =>
this.authService.login(action.credentials)
...
Webpack 无法编译,我收到以下错误:
ERROR in src/app/licencing/effects/licencing.effects.ts(20,69): error TS2339: Property 'environment' does not exist on type 'never'.
Screenshot of code with errors highlighted
我哪里错了?
【问题讨论】:
标签: ngrx-effects angular8