From eb7c52225985337c779530c7505ce19f0af939fa Mon Sep 17 00:00:00 2001 From: Vincent Cote-Roy Date: Wed, 5 Jun 2019 13:39:47 -0400 Subject: [PATCH] Fix Typescript export definitions 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"`. --- packages/isomorphic-unfetch/index.d.ts | 2 +- src/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/isomorphic-unfetch/index.d.ts b/packages/isomorphic-unfetch/index.d.ts index 0c53ad9..4a2ecdd 100644 --- a/packages/isomorphic-unfetch/index.d.ts +++ b/packages/isomorphic-unfetch/index.d.ts @@ -14,4 +14,4 @@ declare namespace unfetch { declare const unfetch: typeof fetch; -export default unfetch; +export = unfetch; diff --git a/src/index.d.ts b/src/index.d.ts index 0c53ad9..4a2ecdd 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -14,4 +14,4 @@ declare namespace unfetch { declare const unfetch: typeof fetch; -export default unfetch; +export = unfetch;