在aot
打开的情况下,Angular 6项目无法在prod中进行编译。
我知道我应该将函数表达式转换为导出的函数,但是随着发生的事情,我无法正确完成它。我到处寻找有类似问题的人,但没有得到他们的帮助。我认为我的情况会更加激烈。
export const createReducer = <T>(type: string) => () => {
return <T>(state = createInitialState<T>(), action: any): IState<T> => {
switch (action.type) {
case `CLEARCACHE_${type}`: {
return state = createInitialState();
}
case `CREATE_${type}`: {
return incrementLoading(state);
}
... Other cases.
}
}
}
export const reducers = {
company: (createReducer(getStoreKey(Company)))(),
mortgages: (createReducer(getStoreKey(Mortgage)))(),
... More of the same.
}
我无法围绕实际发生的事情以及如何对它进行适当的反向工程来包裹我的小脑袋。
让我知道您是否需要更多代码或信息。
这是完整的错误。
ERROR in src\app\data\store\store.module.ts(14,27): Error during template compile of 'StoreModule'
Function expressions are not supported in decorators in 'reducers'
'reducers' references 'createReducer' at src\app\data\store\reducers\index.ts(13,15)
'createReducer' contains the error at src\app\data\store\reducers\generic.reducer.ts(53,30)
Consider changing the function expression into an exported function.