Closed
Description
Bug Report
Current Behavior
I am trying to write a library interface that accepts InteropObservable
for two reasons:
- to allow any Observable implementation to be passed
- I don't want to use
Observable
as an input type, because it is a class, and TypeScript will therefor reject passing in an instance of RxJSObservable
if it is an instance ofObservable
from a different file (different package version, or duplicate because ofnpm link
). Coding against interfaces is better than coding against implementations
I get the error:
Type 'Observable<T>' is not assignable to type 'InteropObservable<T>'.
Property '[Symbol.observable]' is missing in type 'Observable<T>'.
Reproduction
- REPL or Repo link:
https://stackblitz.com/edit/typescript-3v2qer
Expected behavior
I would expect to be able to have my interface accept InteropObservable
, and pass in an RxJS concrete Observable
without a compile error.
Environment
- Runtime: any
- RxJS version: 6.2.1
Possible Solution
Add symbol.observable
to Observable
, and make it implement InteropObservable
?