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

Fix zen-observable import #7004

Conversation

MatthiasKunnen
Copy link

The old import causes the following error:

node_modules/@apollo/client/utilities/observables/Observable.d.ts:1:8 - error TS1259: Module '".../node_modules/@types/zen-observable/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

1 import Observable from 'zen-observable';
         ~~~~~~~~~~

  node_modules/@types/zen-observable/index.d.ts:69:1
    69 export = Observable;
       ~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.

The old import causes the following error:
node_modules/@apollo/client/utilities/observables/Observable.d.ts:1:8 - error TS1259: Module '".../node_modules/@types/zen-observable/index"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

1 import Observable from 'zen-observable';
         ~~~~~~~~~~

  node_modules/@types/zen-observable/index.d.ts:69:1
    69 export = Observable;
       ~~~~~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'allowSyntheticDefaultImports' flag.
@apollo-cla
Copy link

@MatthiasKunnen: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@MatthiasKunnen
Copy link
Author

Hmmm, the correct import style does not seem to be compatible with how apollo-client is using zen-observable. It all originates from the usage of esModuleInterop. I reckon I'd have to until rxjs replaces zen-observable in this repository (#5749)?

@benjamn
Copy link
Member

benjamn commented Sep 11, 2020

Observable is supposed to be a constructor function, but import * as anything from "wherever" will always give you a (module namespace) object for anything, so I don't think this change is quite correct/enough by itself.

@MatthiasKunnen
Copy link
Author

@benjamn, you're right. I'll enable allowSyntheticDefaultImports to fix this problem for now. That being said, it'd be great if installing apollo-client would not require me to change my tsconfig.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants