Я использую ngrx и пытаюсь объединить 2 редуктора.получаю ошибку как
ERROR in src/app/state/index.ts(17,7): error TS2322: Type 'ActionReducer<{}, Action>' is not assignable to type 'ActionReducer<AppState, Action>'.
Type '{}' is missing the following properties from type 'AppState': count, title
не в состоянии понять.как это исправить?
вот мой код: где я получаю ошибку.
import { combineReducers, ActionReducer } from '@ngrx/store';
import { compose } from '@ngrx/core/compose';
import { storeFreeze } from 'ngrx-store-freeze';
import { reducerCount } from "./reducerCount";
import { reducerTitle } from "./reducerTitle";
import { AppState } from "./../models/State";
const reducers = {
redCount : reducerCount,
redTitle : reducerTitle
}
const developmentReducer: ActionReducer<AppState> = compose(storeFreeze, combineReducers)(reducers); //throws error here
export function reducer(state: any, action: any) {
return developmentReducer(state, action);
}
вот мой AppState:
import { TitleState } from "./TitleState";//has model
import { CounterState } from "./CouterState";//has model
export interface AppState {
count : CounterState;
title : TitleState;
}
TitleState.ts
export interface CounterState {
counter:number
}
CouterState.ts
export interface TitleState {
title:string;
}
вот мои редукторы:
export function reducerCount(state=0, action) {
switch (action.type) {
case "INCREMENT":
return state + 1;
case "DECREMENT":
return state - 1;
default:
return state;
}
}
const basicValues = {
title:"ABC"
}
export function reducerTitle(state=basicValues, action) {
switch (action.type) {
case "UPDATE_TITLE":
return {
...state,
title:"TCH"
}
default:
return state;
}
}
Демоверсия здесь => пожалуйста, проверьте состояние -> index.ts