ngrx 5.2 MetaReducer类型不匹配

时间:2018-05-05 16:26:13

标签: angular typescript redux ngrx

我正在尝试新的ngRx v5.2,设置一切正常(减速器,动作)。但是当我通过StoreModule.forRoot(reducers,{metaReducer})初始化我的商店时。我在下面收到错误:

ERROR in src/app/app.module.ts(32,35): 
error TS2345: Argument of type '{ metaReducer: MetaReducer<State, Action>[]; }' is not assignable to parameter of type 'StoreConfig<State, Action>'.
Object literal may only specify known properties, and 'metaReducer' does not exist in type 'StoreConfig<State, Action>'.

./存储/ index.ts

...
export interface State {
  fileUpload:       fromAppFeature1.State;
  //TODO more to add here
}

export const reducers: ActionReducerMap<State> = {
  feature1:   fromAppFeature1.reducer
  //TODO more to add here
};


export function logger(reducer: ActionReducer<State>): ActionReducer<State> {
  return function(state: State, action: any):State {
    console.log('state', state);
    console.log('action', action);
    return reducer(state, action);
  }

}

export const metaReducer: MetaReducer<State>[] = !environment.production ? [logger, storeFreeze] : [];

问题出现我认为自第4版以来,我不确定为什么这仍然没有修复。我该怎么做才能缓解这种类型错误?提前谢谢。

0 个答案:

没有答案