I have defined my reducers like this
import { Action, ActionReducerMap, createAction, createReducer, on } from '@ngrx/store'
import AppUser from 'src/app/shared/models/app-user';
import { AuthActions } from '../auth.action.types';
export interface AppState {
loggedInUser: AppUser
}
export const initialGlobalState: AppState = {
loggedInUser: undefined,
};
export const authReducer = createReducer(
initialGlobalState,
on(AuthActions.loginSuccess, (state, action) => {
return {
// ...state,
loggedInUser: action.loggedInUser,
};
}),
on(AuthActions.logout, (state, action) => {
return {
// ...state,
loggedInUser: undefined,
};
}),
);
export const reducers: ActionReducerMap<AppState> = {
globalState: authReducer,
};
and this reducer is hooked into app.module.ts like this.
StoreModule.forRoot(reducers),
StoreDevtoolsModule.instrument({
maxAge: 25, // Retains last 25 states
logOnly: environment.production, // Restrict extension to log-only mode
}),
EffectsModule.forRoot([AuthEffects])
but I am getting compile error that
TS2322: Type '{ globalState: ActionReducer<AppState, Action>; }' is not assignable to type 'ActionReducerMap<AppState, Action>'.
What am I doing wrong ? kindly help