Skip to content

Fix Typescript export definitions - #116

Open
vincentcr wants to merge 2 commits into
developit:mainfrom
vincentcr:fix-typescript-export
Open

Fix Typescript export definitions#116
vincentcr wants to merge 2 commits into
developit:mainfrom
vincentcr:fix-typescript-export

Conversation

@vincentcr

Copy link
Copy Markdown

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
Copy Markdown

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

Thanks @vincentcr

@developit

Copy link
Copy Markdown
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?

@developitdevelopit added the needs-more-info information is needed to move forward label Feb 18, 2020
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-more-infoinformation is needed to move forwardtypescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@vincentcr@shevchenkonik@developit