Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Fix zen-observable typescript import #623

Closed
wants to merge 3 commits into from

Conversation

dobesv
Copy link

@dobesv dobesv commented May 5, 2018

Because zen observable uses the export = Observable, it should be imported using the form import Observable = require('zen-observable');.

See https://www.typescriptlang.org/docs/handbook/modules.html under the heading "export = and import = require()":

When exporting a module using export =, TypeScript-specific import module = require("module") must be used to import the module.

This error occurs if your tsconfig has

    "esModuleInterop": true,

Setting that option to false prevents the error.

Because zen observable uses the `export = Observable`, it should be imported using the form  `import Observable = require('zen-observable');`.

See https://www.typescriptlang.org/docs/handbook/modules.html under the heading "export = and import = require()":

"When exporting a module using export =, TypeScript-specific import module = require("module") must be used to import the module."
@dobesv
Copy link
Author

dobesv commented May 9, 2018

See also #558

@dobesv
Copy link
Author

dobesv commented May 9, 2018

See also #248

@dobesv
Copy link
Author

dobesv commented May 9, 2018

See also #380 as a possible alternative fix.

@dobesv
Copy link
Author

dobesv commented May 9, 2018

See also #515

@dobesv
Copy link
Author

dobesv commented May 9, 2018

See also #511

@tannerbaum
Copy link

tannerbaum commented Jun 6, 2018

I'm not sure if it is appropriate to comment here, but I have a suspicion that this fix could solve an error that has haunted me for the last three days:

ERROR in [at-loader] ./node_modules/@types/zen-observable/index.d.ts:8:9 TS2687: All declarations of 'observable' must have identical modifiers.

Really hope this PR can be merged.

Edit: actually this was a result of conflicting type imports. But I am glad that the pr has been resolved at least

@dobesv
Copy link
Author

dobesv commented Jun 8, 2018

It seems like recent changes to master have probably made this PR obsolete.

@dobesv dobesv closed this Jun 8, 2018
@nicky-lenaers
Copy link

nicky-lenaers commented Jun 13, 2018

Same issue as @THoisington , still present in 1.2.2

EDIT:
The RXJS package has also updated this, see the PR

@dobesv
Copy link
Author

dobesv commented Jun 13, 2018

@nicky-lenaers You should probably comment on one of the related issues. This PR would have to be redone since the code it was based on has changed in a significant way.

@tannerbaum
Copy link

@nicky-lenaers There is also a PR in zen-observable. For me it was specifically @types/node adding readonly and @types/zen-observable was missing it. Seems like things can really get messy with @types!

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