question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type error with fetch operator and rxjs 7

See original GitHub issue

A type error occurs when using the fetch operator with rxjs 7.

TS2322: Type 'Observable<unknown>' is not assignable to type 'EffectResult<Action>'.   Type 'Observable<unknown>' is not assignable to type 'Observable<Action>'.     Type 'unknown' is not assignable to type 'Action'
import {Injectable} from "@angular/core";
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { fetch } from '@nrwl/angular';

@Injectable()
class TodoEffects {
  loadTodo$ = createEffect(() =>
    this.actions$.pipe(
      ofType('GET_TODO'),
      fetch({
        run: (action) => {
          return ({
            type: 'LOAD_TODO_SUCCESS',
          });
        },
      })
    )
  );

  constructor(private actions$: Actions) {}
}

When you downgrade to rxjs 6 the error disappears.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Frankitchcommented, Aug 30, 2022

I’ve found a solution for npm

0reactions
irowbincommented, Dec 6, 2022

I am facing the same issue updating to Nx 15 using Node 16 and npm 9. What‘s the recommended fix?

In my case, I did https://github.com/nrwl/nx/discussions/10692#discussioncomment-3507611 and the error is gone. Not sure if its a correct solution but it does helped me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NgRX effects - Type 'Observable<unknown>' is not assignable ...
I agree, this error appears if one of the operators or observable "constructors" are not imported. But it also appears if types are...
Read more >
RxJs Error Handling: Complete Practical Guide
The catchError operator takes as input an Observable that might error out, and starts emitting the values of the input Observable in its...
Read more >
RxJS 6.x to 7.x Detailed Change List
This document contains a detailed list of changes between RxJS 6.x and RxJS 7.x, presented in the order they can be found when...
Read more >
Chapter 7. Error handling with RxJS - RxJS in Action
The issues with imperative error–handling schemes; Using functional data types to abstract exception handling; Using observable operators to handle ...
Read more >
What's New in RxJS 7 - Medium
The Promise returned by toPromise can indeed emit undefined . There is no way to tell the difference from an error state. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found