I have encountered a persistent error in my main.module.ts. The code snippet triggering the error is as follows:
@NgModule({
declarations: [
PressComponent,
LegalComponent,
InviteComponent
],
providers: [
AuthService
],
imports: [
HomeModule,
MainRoutingModule,
ContactModule,
EffectsModule.forRoot([
AuthEffects
]),
StoreModule.forRoot(AuthReducer, {
metaReducers,
runtimeChecks: {
strictActionImmutability: true,
strictStateImmutability: true,
},
}),
SectionHeaderGroupModule,
FormRegisterModule,
ReactiveFormsModule
]
})
export class MainModule {
}
The specific error message that I am encountering reads:
Error:(34, 25) TS2345: Argument of type '(state: State, action: AuthActionsUnion) => State' is not assignable to parameter of type 'ActionReducerMap<State, Action> | InjectionToken<ActionReducerMap<State, Action>>'.
Type '(state: State, action: AuthActionsUnion) => State' is not assignable to type 'InjectionToken<ActionReducerMap<State, Action>>'.
Property '_desc' is missing in type '(state: State, action: AuthActionsUnion) => State'.
In an effort to resolve this issue, you can refer to my auth.reducer.ts file for context:
import { IUser } from '../shared/models/user';
import * as AuthActions from './auth.actions';
export interface State {
user: IUser | null;
error: any;
}
const initialState: State = {
user: null,
error: '',
};
export function AuthReducer(state = initialState, action: AuthActions.AuthActionsUnion): State {
switch (action.type) {
case AuthActions.AuthActionsTypes.GetUserDataGoogleSignIn: {
return {
...state,
user: action.payload,
error: '',
};
}
// Other cases omitted for brevity
}
}
function getErrorMessage(error): string {
switch (error) {
case 'auth/wrong-password':
return 'Wrong password';
case 'auth/user-not-found':
return 'IUser does not exist';
case 'auth/invalid-email':
return 'Invalid email address';
default:
return error;
}
}
If you have any insights or solutions on how to rectify this error, kindly share them with me.