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

Global declaration of Observable causes issues when using latest rxjs #7839

Closed
ntziolis opened this issue Mar 14, 2021 · 2 comments · Fixed by #7888
Closed

Global declaration of Observable causes issues when using latest rxjs #7839

ntziolis opened this issue Mar 14, 2021 · 2 comments · Fixed by #7888

Comments

@ntziolis
Copy link

The globally declared Observable interface is not compatible with rxjs/Observable. This causes the following error when declaring variables of type Observable:

error "Property '['@@observable']' is missing in type rxjs/Observable

While this can be resolved by manually adding the import. It breaks editor auto import functionality as the editor thinks Observable is already a known type. This is a major pain as rxjs/Observable is used in nearly everywhere (angular app).

We are currently using patch-package @apollo/client@3.3.11 to completely remove the global declaration. This re-enables normal editor flow without us noticing any side effects.

While this is an issue that is angular related its not something that can be solved in the apollo-angular package alone. Hence filing this issue here.

We currently assume that the current versions of rxjs/Observable is simply not compatible with the global declaration anymore.

Lib versions:

    "@apollo/client": "^3.3.11",
    "apollo-angular": "^2.4.0",
    "rxjs": "~6.6.3",

Here is the diff from patch-package:

diff --git a/node_modules/@apollo/client/utilities/observables/Observable.d.ts b/node_modules/@apollo/client/utilities/observables/Observable.d.ts
index dd1ed9a..56f471f 100644
--- a/node_modules/@apollo/client/utilities/observables/Observable.d.ts
+++ b/node_modules/@apollo/client/utilities/observables/Observable.d.ts
@@ -3,10 +3,10 @@ import 'symbol-observable';
 export declare type ObservableSubscription = ZenObservable.Subscription;
 export declare type Observer<T> = ZenObservable.Observer<T>;
 export declare type Subscriber<T> = ZenObservable.Subscriber<T>;
-declare global {
-    interface Observable<T> {
-        ['@@observable'](): Observable<T>;
-    }
-}
+// declare global {
+//     interface Observable<T> {
+//         //['@@observable'](): Observable<T>;
+//     }
+// }
 export { Observable };
 //# sourceMappingURL=Observable.d.ts.map
\ No newline at end of file
@benjamn
Copy link
Member

benjamn commented Mar 23, 2021

@ntziolis Thanks for bringing this to our attention. Fix in progress: #7888

@ntziolis
Copy link
Author

That was wicked fast!

@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 a pull request may close this issue.

2 participants