Reputation: 66435
Typescript has built in defs for whatwg-fetch
now (I'm using v2.7), however it ignores them with dynamic imports:
import(/* webpackChunkName: "whatwg-fetch" */ 'whatwg-fetch')
TS7016: Could not find a declaration file for module 'whatwg-fetch'. 'C:/../node_modules/whatwg-fetch/fetch.js' implicitly has an 'any' type. Try
npm install @types/whatwg-fetch
if it exists or add a new declaration (.d.ts) file containingdeclare module 'whatwg-fetch';
However if I install that the @types/whatwg-fetch
type module as it suggests it has dozens of errors about duplicate definitions due to already having it built in...
How can I circumvent this issue? Thanks
Upvotes: 0
Views: 1274
Reputation: 66435
I've solved this by created a d.ts file - whatwg-fetch.d.ts
with this inside:
declare module "whatwg-fetch";
Upvotes: 1