简体   繁体   English

Ngrx StoreModule declaration forRoot error Angular 9

[英]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 版本重现,请随时重新打开(或创建新的)此重现问题。

Also here they say:他们也在这里说:

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.

相关问题 ngrx StoreModule.forRoot 命名约定 - ngrx StoreModule.forRoot Naming convention NgRx StoreModule.forRoot - 在没有根级减速器时指定元减速器 - NgRx StoreModule.forRoot - specify metareducers when there is no root level reducer 如何使用ngrx的StoreModule.forRoot()和StoreModule.forFeature()访问另一个模块存储 - How to access another modules store with ngrx's StoreModule.forRoot() and StoreModule.forFeature() StoreModule.forRoot() 中的 Reducer 名称 - Reducer name in StoreModule.forRoot() 如何使用Angular2 ngrx storemodule reducer(initialState)注入服务? - how to use Angular2 ngrx storemodule reducer (initialState) inject service? Angular 4,ngrx \\ store Plunker-TypeError:store_1.StoreModule.provideStore不是一个函数 - Angular 4, ngrx\store Plunker - TypeError: store_1.StoreModule.provideStore is not a function @ngrx/store@11.0.0 'StoreModule' 模板编译期间出错 - @ngrx/store@11.0.0 Error during template compile of 'StoreModule' StoreModule.forRoot() 和 StoreModule.forFeature() 有什么区别 - What is the difference between StoreModule.forRoot() and StoreModule.forFeature() 使用 StoreModule.forRoot 或 StoreModule.forFeature 哪个? - Which to use StoreModule.forRoot or StoreModule.forFeature? 如何为我的 angular 应用程序注册 ngrx 子功能 (StoreModule.forFeature())? - How to register ngrx sub features (StoreModule.forFeature()) for my angular app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM