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

Schematics generates invalid effect in NGRX 11 w/ ng generate effect [module] #2931

Closed
VFiber opened this issue Feb 18, 2021 · 0 comments · Fixed by #3005
Closed

Schematics generates invalid effect in NGRX 11 w/ ng generate effect [module] #2931

VFiber opened this issue Feb 18, 2021 · 0 comments · Fixed by #3005

Comments

@VFiber
Copy link

VFiber commented Feb 18, 2021

Create a project with @ngrx/scehmatics and @ngrx/effect

Generate a new module:

ng generate module test

Create a new feature with ngrx/schematics:

ng generate feature TestFeature

With default parameters it creates an invalid NGRX 11 effect:

export class TestFeatureEffects {


  loadTestFeatures$ = createEffect(() => {
    return this.actions$.pipe( 

      ofType(TestFeatureActions.loadTestFeatures),
      /** An EMPTY observable only emits completion. Replace with your own observable API request */
      concatMap(() => EMPTY)
    );
  });


  constructor(private actions$: Actions) {}

}

It dispatches an EMPTY, what causes :

    ERROR in src/app/test-module/effect-test-module/test/test-feature.effects.ts:14:36 - error TS2345: Argument of type '() => Observable<never>' is not assignable to parameter of type '() => never'.
      Type 'Observable<never>' is not assignable to type 'never'.
    
    14   loadTestFeatures$ = createEffect(() => {
                                          ~~~~~~~
    

According to the introduction of the new typechecks this is an error without specifying {dispatch: false} in the EffectConfig.

Expected behavior:

It creates a new effect with {dispatch: false}.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

NGRX 11.0.0 / @ngrx/schematics 11.0.0. / Angular 11.1.2

I believe it was introduced due to the stricter type-checks in NGRX 11, should work with pre-11 versions.

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

Successfully merging a pull request may close this issue.

2 participants