-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observable does not implement InteropObservable #3890
Comments
Interesting. afaik Still, I thought Observable already implemented |
Adding |
Me too, just thought we already did it. Not sure if it's related with decision we removed polyfill to symbol.observable? |
|
It definitely is not in the published .d.ts: https://unpkg.com/rxjs@6.2.1/internal/Observable.d.ts |
This looks to be a TypeScript issue, as this: import { EMPTY, InteropObservable } from "rxjs";
import { observable } from "rxjs/internal/symbol/observable";
class Something {
[observable]() { return EMPTY; }
}
declare const s: Something;
const i: InteropObservable<never> = s; effects this error:
|
@felixfbecker Its being missing could be related to what appears to be a TypeScript problem. |
Actually, it's not TypeScript. The problem - well, at least part of the problem - is that the export type InteropObservable<T> = { [Symbol.observable]: () => Subscribable<T>; }; Basically, it does so because TypeScript will not allow the
Changing the snippet to this works fine: import { EMPTY, InteropObservable } from "rxjs";
class Something {
[Symbol.observable]() { return EMPTY; }
}
declare const s: Something;
const i: InteropObservable<never> = s; |
@cartant as we have a solution posted in your last comment I believe we can close this issue |
I believe that there's not much more we can do for this issue at this time. There's an adequate workaround in this comment |
Bug Report
Current Behavior
I am trying to write a library interface that accepts
InteropObservable
for two reasons: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 implementationsI get the error:
Reproduction
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 concreteObservable
without a compile error.Environment
Possible Solution
Add
symbol.observable
toObservable
, and make itimplement InteropObservable
?The text was updated successfully, but these errors were encountered: