Skip to content

Commit

Permalink
Remove global Observable<T>["@@observable"] method declaration. (#7888)
Browse files Browse the repository at this point in the history
Should fix #7839.
  • Loading branch information
benjamn authored Mar 24, 2021
1 parent 839b058 commit dcb5f11
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/utilities/observables/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ export type ObservableSubscription = ZenObservable.Subscription;
export type Observer<T> = ZenObservable.Observer<T>;
export type Subscriber<T> = ZenObservable.Subscriber<T>;

// Use global module augmentation to add RxJS interop functionality. By
// using this approach (instead of subclassing `Observable` and adding an
// ['@@observable']() method), we ensure the exported `Observable` retains all
// existing type declarations from `@types/zen-observable` (which is important
// for projects like `apollo-link`).
declare global {
interface Observable<T> {
['@@observable'](): Observable<T>;
}
// The zen-observable package defines Observable.prototype[Symbol.observable]
// when Symbol is supported, but RxJS interop depends on also setting this fake
// '@@observable' string as a polyfill for Symbol.observable.
const { prototype } = Observable;
const fakeObsSymbol = '@@observable' as keyof typeof prototype;
if (!prototype[fakeObsSymbol]) {
prototype[fakeObsSymbol] = function () { return this; };
}
(Observable.prototype as any)['@@observable'] = function () { return this; };

export { Observable };

0 comments on commit dcb5f11

Please sign in to comment.