Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EffectsModule breaks on RxJS6 #949

Closed
spock123 opened this issue Apr 2, 2018 · 10 comments
Closed

EffectsModule breaks on RxJS6 #949

spock123 opened this issue Apr 2, 2018 · 10 comments

Comments

@spock123
Copy link

spock123 commented Apr 2, 2018

Hi,
after upgrading to the 6.0.0 beta.0 I am having issues with the effects module.

Even the simplest effects module with an empty array of effects still gives the following error when importing the EffectsModule:

..... misc imports

import { reducers } from './my-store';
let effects: Array<any> = [];

@NgModule({
  imports: [
    BrowserModule,
    RouterModule.forRoot(routes),
    StoreModule.forRoot(reducers),
    EffectsModule.forRoot(effects)
  ],
...

Notice the EffectsModule is called with no effects. If I remove the EffectsModule line everything works.
The error when including the EffectsModule is:

Error: StaticInjectorError(AppModule)[EffectsRootModule -> Store]: 
  StaticInjectorError(Platform: core)[EffectsRootModule -> Store]: 
    NullInjectorError: No provider for Store!

Dependencies:

Angular 6.0.0 RC.1
RxJS 6.0.0 RC.0
Ngrx/store, Ngrx/effects : 6.0.0-beta.0
Ngrx/core: 1.2.0 (now removed)
Typescript: 2.7.1 / 2.8.1

@sandangel
Copy link
Contributor

sandangel commented Apr 2, 2018

Ngrx/core: 1.2.0

Why do you need ngrx/core ? I think this package has been removed since ngrx v4.

@spock123
Copy link
Author

spock123 commented Apr 2, 2018

@sandangel Good question lol... I'll remove it and see what happens :)

Update - same issue. I wasn't using ngrx/core, it was just in my package.json for some reason. Thanks for pointing out that I can remove it.

@MakesNine
Copy link

I have the same issue after upgrading to Ngrx 6.0.0-beta.0. However, it works if I run "ng serve --aot" instead of "ng serve". I found that workaround while searching previous related issues like #184

From what I understand, the Store module has to be loaded before loading other Ngrx modules, but for some reason the Store module is not found when running the app with the JIT compiler. With aot, the right module gets imported and the app runs without any problem in my case.

@sylvaindumont
Copy link
Contributor

same problem, ng serve and ng build with aot work fine, but ng test which doesn't support aot causes

Error: StaticInjectorError(AppModule)[EffectsRootModule -> Store]: 
  StaticInjectorError(Platform: core)[EffectsRootModule -> Store]: 
    NullInjectorError: No provider for Store!

@MikeRyanDev
Copy link
Member

I think this is the first bug where it works correctly with AOT and incorrectly with JIT 🤨

@MakesNine
Copy link

I have created a simple project that reproduces the issue: https://github.com/MakesNine/testapp

Project works using "ng serve --aot" but doesn't work with "ng serve".

@spock123
Copy link
Author

spock123 commented Apr 2, 2018

@MakesNine thanks!
I also have a repo demonstrating the same issue.

https://github.com/spock123/ngrx-effects-test

I am NOT using the CLI but using a custom webpack build.

Glad I'm not the only one with the issue, was going mad :) lol
Thanks guys! Appreciate it

@MikeRyanDev
Copy link
Member

v6.0.0-beta.1 of NgRx has been released with a fix for this bug.

@SheriffKhan
Copy link

When I am importing StoreModule in app module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
By only importing StoreModule in below line, erros is coming...
import { StoreModule } from '@ngrx/store'; 
import { AppComponent } from './app.component';

// import { reducer } from './reducers/Tutorial.reducer';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    StoreModule.forRoot({}) 
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Below error is coming, kindly help me to resolve this....

ERROR in node_modules/@ngrx/store/src/action_creator.d.ts(11,124): error TS2344: Type 'ParametersType<C>' does not satisfy the constraint 'any[]'.
  Type '{}' is not assignable to type 'any[]'.
    Type '{}' is not assignable to type 'any[]'.
      Property 'includes' is missing in type '{}'.
node_modules/@ngrx/store/src/models.d.ts(30,58): error TS2304: Cannot find name 'unknown'.
node_modules/@ngrx/store/src/models.d.ts(30,82): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,52): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,73): error TS2304: Cannot find name 'unknown'.

@AlbinLijo
Copy link

When I am importing StoreModule in app module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
By only importing StoreModule in below line, erros is coming...
import { StoreModule } from '@ngrx/store'; 
import { AppComponent } from './app.component';

// import { reducer } from './reducers/Tutorial.reducer';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    StoreModule.forRoot({}) 
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Below error is coming, kindly help me to resolve this....

ERROR in node_modules/@ngrx/store/src/action_creator.d.ts(11,124): error TS2344: Type 'ParametersType<C>' does not satisfy the constraint 'any[]'.
  Type '{}' is not assignable to type 'any[]'.
    Type '{}' is not assignable to type 'any[]'.
      Property 'includes' is missing in type '{}'.
node_modules/@ngrx/store/src/models.d.ts(30,58): error TS2304: Cannot find name 'unknown'.
node_modules/@ngrx/store/src/models.d.ts(30,82): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,52): error TS2370: A rest parameter must be of an array type.
node_modules/@ngrx/store/src/models.d.ts(31,73): error TS2304: Cannot find name 'unknown'.

StoreModule.forRoot([ ])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants