question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript issue: weird dependency on node-fetch in declaration file

See original GitHub issue

First of all thanks for awesome polyfill @developit. It’s brilliant and altogether with preact it makes a perfect match for our product bundle!

As for this issue I’m not sure why there’s a dependency on node-fetch in declaration file. When I try to use unfetch in my TS code I get this:

ERROR in [at-loader] ./node_modules/unfetch/src/index.d.ts:6:8 
        TS7016: Could not find a declaration file for module 'node-fetch'. '/Users/dsorin/.../node_modules/node-fetch/index.js' implicitly has an 'any' type.
      Try `npm install @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`

I know this can be fixed by installing typings for node-fetch but this leads to a further questions like “what’s this typing doing in our dependencies if we don’t use node-fetch package? let’s remove it”.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
1999commented, Oct 14, 2018

Fair enough 👍

1reaction
mindplay-dkcommented, Aug 2, 2021

Is this why I’m getting a TypeScript error when I compile my project?

node_modules/unfetch/src/index.d.ts:7:8 - error TS2307: Cannot find module 'node-fetch' or its corresponding type declarations.

7 } from "node-fetch";
         ~~~~~~~~~~~~

If the typings in @types/node-fetch work, I don’t know why it’s a problem to just reuse those? But either way, it’s currently an undeclared dependency - you have to get a build failure and then manually install the package, so I think either that should be fixed, or the dependency should be removed?

(I don’t use the isomorphic stuff, so it’s all the same to me - but having a broken dependency definitely isn’t great.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not find a declaration file for module 'module-name ...
In Node.js everything works fine, but TypeScript: import {Injector} from '@ts-stack/di' ...
Read more >
could not find a declaration file for module 'node-fetch' - You.com
React Typescript throws the error, could not find a declaration file for module, due to number of reasons. Check out the possible solutions...
Read more >
How to fix error TS7016: Could not find a declaration file for ...
Try `npm install @types/XYZ` if it exists or add a new declaration (.d.ts) file containing `declare module 'XYZ';. If XYZ is a direct...
Read more >
node-fetch - npm
node -fetch. TypeScript icon, indicating that this package has built-in type declarations · Readme · Code Beta · 3 Dependencies · 28,953 Dependents ......
Read more >
Note To Self: Adding Type Declaration Files To A TypeScript ...
As you can see, I am deleting the TypeScript compiler cache before each run. This way, I make sure I get the least...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found