Problem with types while using RXjs with React

Viewed 133

I know this could not be related to particular react but while using Rxjs Im getting errors from typescript, Im trying to solve this for some time now , type casting/ explicit casting also not working. Im getting type error while trying to use operators on any kind of Observable

Types of parameters 'subscriber' and 'subscriber' are incompatible.             Type 'Subscriber<any>' is missing the following properties from type 'Subscriber<any>': syncErrorValue, syncErrorThrown, syncErrorThrowable, _unsubscribeAndRecycle, and 2 more.

While using for ex. map in pipe:

Observable

import { fromEvent, Observable} from 'rxjs';
import { map} from 'rxjs/operators';
const discoveredPeripheral$: Observable<Peripheral> = fromEvent<Peripheral>(
  bleManagerEmitter,
  'BleManagerDiscoverPeripheral'
);

subscription:

  useEffect(() => {
    discoveredPeripheral$
      .pipe(
        map(emitter => emitter)
      //errror for map / any type of operator
      )
      .subscribe((emitter: Peripheral) => console.log('EMITTER', emitter));

Am I doing something wrong here?

RXJS version 7.5.5

I tried with many operator , type casting without success/ Trying with observables from subjects as well.

0 Answers
Related