ngrx store Combine Reducer 将错误抛出为`错误 TS2322:类型 'ActionReducer<{}, Action>' 不可分配`

ngrx store Combine Reducer throw error as ` error TS2322: Type 'ActionReducer<{}, Action>' is not assignable`

我正在使用 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;
    }
}

Live Demo here => 请检查状态 -> index.ts

AppState 的形状不符合您在 combineReducers() 中提供的国家和平。回复:

export interface AppState {
    counter : CounterState;
    title : TitleState;
}

进入:

export interface AppState {
    countReducer : CounterState;
    titleReducer : TitleState;
}

并注意 - 当您设置 StoreModule.forRoot()StoreModule.forFeature()

时,NGRX 中的 combineReducers() 被隐式使用