Sitelet https://web.archive.org/web/20201201154836/https://github.com/developit/unfetch/pull/116
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 Typescript export definitions #116

Open
wants to merge 2 commits into
base: master
from

Conversation

@vincentcr
Copy link

@vincentcr vincentcr commented Jun 5, 2019

Typescript does not support .mjs files, so the module that ends up being imported is the commonJS version (dist/unfetch.js). Since that file does not contain a default export entry, using it in Typescript results in a runtime error: TypeError: isomorphic_unfetch_1.default is not a function

Fix by reverting to export =. To use in Typescript, use the form import * as fetch from "isomorphic-unfetch".

Typescript does not support .mjs file, so the module that ends up being
imported is the commonJS version (`dist/unfetch.js`). Since it does not contain a
"default" export entry, using it in Typescript results in a runtime
error: `TypeError: isomorphic_unfetch_1.default is not a function`

Fix by reverting to `export =`. To use in Typescript, use the form
`import * as fetch from "isomorphic-unfetch"`.
@shevchenkonik
Copy link

@shevchenkonik shevchenkonik commented Jun 18, 2019

Yes, I have similar problem and this PR will solve it.

Thanks @vincentcr

@developit
Copy link
Owner

@developit developit commented Feb 18, 2020

I believe this should be addressed by #135, which drops the .mjs file extension and moves back to unfetch.module.js. Can anyone confirm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.