简体   繁体   中英

Ngrx StoreModule declaration forRoot error Angular 9

Only by declaring the StoreModule on the code below:

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?

Thanks by now

Take a look at this 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:

...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.

Also here they say:

NgRx v11 expects TypeScript 4 to be used and Angular 11.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM