matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.96k stars 290 forks source link

Isomorphic-fetch Typescript setup #196

Open Coruscate5 opened 3 years ago

Coruscate5 commented 3 years ago

After installing the types and isomorphic-fetch from npm, I get the following error in Typescript:

TS2349:  (TS) This expression is not callable.
  Type '{ default: (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>; }' has no call signatures.

In my Saga, I simply call fetch normally:

yield fetch(someInterpolatedApiCall);

Forgive me, I've read as much as I can without giving myself an aneurysm - I'm having difficulty understanding what the fix normally is for Typescript. I import the lib using "import * as fetch from 'isomorphic-fetch'". As far as I can tell, the error may be valid because of default-importing, but I don't know what I need to do to satisfy TS. The call does work, but I'm trying to remove the persistent error.

Coruscate5 commented 3 years ago

Gave it a shot - I've abandoned using isomorphic-fetch for the time being

simPod commented 2 years ago

What do you use instead?