Home > Software design >  switchMap gives OperatorFunction<unknown, any>' is not assignable
switchMap gives OperatorFunction<unknown, any>' is not assignable

Time:11-07

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

CodePudding user response:

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.

  • Related