2

I need to switch a stream to an other stream, so I did

 this.appState.domain$.pipe(switchMap(() => of(10))

enter image description here

It gives me an error

OperatorFunction<unknown, any>' is not assignable to parameter of type OperatorFunction<unknown, any>' ....

For me, the error doesn't really tell me what is happening or how to fix this. I would expect this to work, but something is off. Any suggestions why typescript is complaining?

Example: enter image description here

Jeanluca Scaljeri
  • 26,343
  • 56
  • 205
  • 333

1 Answers1

3

If you look closely, you have some mixup between rxjs libraries.

One is expecting /node_modules/rxjs/internal/types/Observable

vs. of(10) returning /node_modules/rxjs/dist/types/internal/types/Observable

Check your import line on the "of" operator, make sure its correct.

IMDB
  • 74
  • 4
  • Nice catch! I checked the imports but they look ok (see my updated post). I can confirm that it only happens in my angular app and not elsewhere. So your finding should be it, but I guess it is not the import of `of` – Jeanluca Scaljeri Nov 06 '21 at 18:19
  • 1
    It is solved. I removed `node_modules` and installed it again – Jeanluca Scaljeri Nov 06 '21 at 18:49