What causes the type error to be thrown when using interval(500)
in the code snippet below?
const source = timer(0, 5000);
const example = source.pipe(switchMap(() => interval(500)));
const subscribe = example.subscribe(val => console.log(val));
Visit StackBlits for more details.
The argument 'UnaryFunction<Observable<number>, Observable<number>>' cannot be assigned to the parameter of type 'OperatorFunction'.
The parameters 'source' are not compatible.
Type 'Observable<any>' cannot be assigned to type 'Observable<number>'.
Property 'source' is protected but type 'Observable<T>' is not a subclass of 'Observable<T>'.}
This issue is encountered in the first switchMap example from learnrxjs.io.