Typescript issue: weird dependency on node-fetch in declaration file
See original GitHub issueFirst 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:
- Created 5 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fair enough 👍
Is this why I’m getting a TypeScript error when I compile my project?
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.)