[英]Ngrx StoreModule declaration forRoot error Angular 9
Only by declaring the StoreModule on the code below:仅通过在以下代码中声明 StoreModule:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { StoreModule } from '@ngrx/store';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
StoreModule.forRoot({})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
I'm having the following error:我有以下错误:
Failed to compile.
node_modules/@ngrx/store/src/reducer_creator.d.ts:32:99 - error TS1005: ',' expected.
32 export declare function on<State, Creators extends readonly ActionCreator[]>(...args: [...creators: Creators, reducer: OnReducer<State, Creators>]): ReducerTypes<State, Creators>;
~
node_modules/@ngrx/store/src/reducer_creator.d.ts:32:118 - error TS1005: ',' expected.
32 export declare function on<State, Creators extends readonly ActionCreator[]>(...args: [...creators: Creators, reducer: OnReducer<State, Creators>]): ReducerTypes<State, Creators>;
Even if I create a reducer and declare it within the method, the error persists Any idea how to solbe this?即使我创建了一个 reducer 并在方法中声明了它,错误仍然存在知道如何解决这个问题吗?
Thanks by now现在谢谢
Take a look at this https://github.com/ngrx/platform/issues/2924 .看看这个https://github.com/ngrx/platform/issues/2924 。 Someone solved it downgrading to @ngrx/store": "^10.1.2
but at the end it seems related to the version of your typescript, angular and/or ngrx in general:有人解决了它降级到@ngrx/store": "^10.1.2
但最后它似乎与您的 typescript、angular 和/或 ngrx 的版本有关:
...in all of the cases the culprit was a lower version of TypeScript. If this issue is reproducible with the latest angular version, and the latest ngrx version, feel free to reopen (or create a new) this issue with the reproduction. ...在所有情况下,罪魁祸首是 TypeScript 的较低版本。如果此问题可通过最新的 angular 版本和最新的 ngrx 版本重现,请随时重新打开(或创建新的)此重现问题。
NgRx v11 expects TypeScript 4 to be used and Angular 11. NgRx v11 期望使用 TypeScript 4 和 Angular 11。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.