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: main
Choose a base branch
from

Conversation

vincentcr
Copy link

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

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

Thanks @vincentcr

@developit
Copy link
Owner

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

@developit developit added the needs-more-info information is needed to move forward label Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-info information is needed to move forward typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants