Property 'connect' does not exist on type 'Observable<any>' | RXJS multicast
You're actually correct here. The multicast
operator really returns an instance of ConnectableObservable
(https://github.com/ReactiveX/rxjs/blob/master/src/internal/operators/multicast.ts#L54).
This is just an issue with TypeScript types where pipe()
always returns just Observable
:(https://github.com/ReactiveX/rxjs/blob/master/src/internal/Observable.ts#L301-L311).
This has been reported and there's an opened issue in RxJS's GitHub page: https://github.com/ReactiveX/rxjs/issues/2972
The easiest workaround is to force override the returned Observable
:
const source4$ = interval(1000).pipe(...) as ConnectableObservable<number>