Skip to content
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

Remove global Observable<T>["@@observable"] method declaration. #7888

Merged
merged 2 commits into from
Mar 24, 2021

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Mar 23, 2021

Should fix #7839.

I find it surprising that setting Observable.prototype['@@observable'] is necessary in addition to setting Observable.prototype[Symbol.observable] (which zen-observable already does), but if you comment out

  prototype[fakeObsSymbol] = function () { return this; };

and run our test suite, you will see failures:

 FAIL  core/__tests__/QueryManager/index.ts (20.796 s)
  ● QueryManager › supports interoperability with other Observable implementations like RxJS

    TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

      577 |     });
      578 | 
    > 579 |     const observable = from(handle as any);
          |                        ^
      580 | 
      581 |     observable.pipe(map(result => assign({ fromRx: true }, result))).subscribe({
      582 |       next: wrap(reject, newResult => {

      at Object.<anonymous>.exports.subscribeTo (../node_modules/rxjs/src/internal/util/subscribeTo.ts:27:11)
      at Object.from (../node_modules/rxjs/src/internal/observable/from.ts:114:30)
      at Object.<anonymous> (core/__tests__/QueryManager/index.ts:579:24)
      at utilities/testing/itAsync.ts:11:37
      at Object.<anonymous> (utilities/testing/itAsync.ts:10:12)

@brainkim
Copy link
Contributor

👍 Interesting that the issue requires runtime changes, and wondering why the TypeError wasn’t thrown before or caught by the test suite.

@benjamn
Copy link
Member Author

benjamn commented Mar 24, 2021

@brainkim This PR would solve #7839 if I merely deleted the declare global { ... } part, but I decided to make the runtime part slightly more defensive while I was at it.

@benjamn benjamn merged commit dcb5f11 into main Mar 24, 2021
benjamn added a commit that referenced this pull request Mar 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global declaration of Observable causes issues when using latest rxjs
2 participants