我正在尝试使用aot构建我的angular 7项目,但是aot抛出以下错误
ERROR in app/app.store.ts(10,25): Error during template compile of 'AppStoreModule'
Function expressions are not supported in decorators in 'auth'
'auth' references 'auth'
'auth' contains the error at app/state/auth/auth.reducers.ts(12,41)
Consider changing the function expression into an exported function.
我已经检查了ngrx reducer的身份验证,如下所示
export const auth: ActionReducer<any> = (
state = initialState,
action: authActions
) => {
switch (action.type) {
case Auth.AUTH_REFRESH:
case Auth.AUTH_LOGIN:
console.log(" reducer called");
return Object.assign({}, state);
case Auth.AUTH_LOGIN_SUCCESS:
console.log("login success reducer");
let token = localStorage.getItem("token");
const decodedToken = helper.decodeToken(token);
console.log(decodedToken.sub);
return Object.assign({}, state, {
currentUser: decodedToken.sub,
loggedIn: !helper.isTokenExpired(token)
});
default:
return state;
}
};
这是我的AppStoreModule
@NgModule({
imports: [
StoreModule.forRoot({
auth,
app,
search
}),
EffectsModule.forRoot([AuthEffects, AppEffects, SearchEffects])
]
})
我不知道代码有什么问题。