unfetch icon indicating copy to clipboard operation
unfetch copied to clipboard

Fix Typescript export definitions

Open vincentcr opened this issue 6 years ago • 2 comments

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".

vincentcr avatar Jun 05 '19 17:06 vincentcr

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

Thanks @vincentcr

shevchenkonik avatar Jun 18 '19 16:06 shevchenkonik

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 avatar Feb 18 '20 15:02 developit