【发布时间】:2021-02-13 16:24:50
【问题描述】:
所以我今天早上将@ngrx 更新为最新版本:
- "@ngrx/effects": "10.1.2",
- "@ngrx/router-store": "10.1.2",
- "@ngrx/store": "10.1.2",
+ "@ngrx/effects": "11.0.0",
+ "@ngrx/router-store": "11.0.0",
+ "@ngrx/store": "11.0.0",
@angular/core 之前已经迁移到@^11.0.0,一切都与@ngrx/store@10.1.2 配合得很好。当然,尽管peerDependency 无效。
现在我的构建 (ng build [PROJECT_NAME]) 遇到了抛出错误:
An unhandled exception occurred: @ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
Expression form not supported.
@ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
Expression form not supported.
@ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
Expression form not supported.
@ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
Expression form not supported.
@ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
Expression form not supported.
@ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
Expression form not supported.
我已经发现,原因与我在子模块中导入的StoreModule.forFeature('auth', reducers) 有关。根AppModule 导入StoreModule.forRoot(reducers, { metaReducers }),。我真的找不到错误,功能缩减器组合如下:
export interface AuthStateData {
status: fromAuth.AuthStateData;
loginPage: fromLoginPage.LoginStateData;
}
export const reducers: ActionReducerMap<AuthStateData> = {
status: fromAuth.reducer,
loginPage: fromLoginPage.reducer
};
有没有人遇到过类似的问题?并在最好的情况下找到解决方案?
不,(很遗憾)我的代码不是开源的。
【问题讨论】:
-
我刚刚向 ngrx 团队报告了同样的问题:github.com/ngrx/platform/issues/2919#issuecomment-776888606 我刚刚降级到 v10 以保持我的项目运行。
标签: angular typescript ngrx ngrx-store angular11