繁体   English   中英

Ngrx StoreModule declaration forRoot error Angular 9

[英]Ngrx StoreModule declaration forRoot error Angular 9

仅通过在以下代码中声明 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 { }

我有以下错误:

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

即使我创建了一个 reducer 并在方法中声明了它,错误仍然存在知道如何解决这个问题吗?

现在谢谢

看看这个https://github.com/ngrx/platform/issues/2924 有人解决了它降级到@ngrx/store": "^10.1.2但最后它似乎与您的 typescript、angular 和/或 ngrx 的版本有关:

...在所有情况下,罪魁祸首是 TypeScript 的较低版本。如果此问题可通过最新的 angular 版本和最新的 ngrx 版本重现,请随时重新打开(或创建新的)此重现问题。

他们也在这里说:

NgRx v11 期望使用 TypeScript 4 和 Angular 11。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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