Giter Club home page Giter Club logo

Comments (9)

1999 avatar 1999 commented on August 25, 2024 3

Fair enough 👍

from unfetch.

mindplay-dk avatar mindplay-dk commented on August 25, 2024 1

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.)

from unfetch.

1999 avatar 1999 commented on August 25, 2024

Maybe @niedzielski knows the answer as the git blame author for this commit?

from unfetch.

niedzielski avatar niedzielski commented on August 25, 2024

It was probably a mistake. Our project at the time was using isomorphic-unfetch which already specified node-fetch as a dependency and I likely conflated them. I see a definition of fetch in the TypeScript DOM library that can probably be used instead. I wish I could remember more detail but I think at the time there was also a difference in the quality of the typings and node-fetch provided something over fetch but that really only mattered to isomorphic-unfetch clients.

from unfetch.

1999 avatar 1999 commented on August 25, 2024

Gotcha. Are you okay if I send a PR to improve this?

from unfetch.

niedzielski avatar niedzielski commented on August 25, 2024

@1999, sure, I'm just a random contributor. It's up to @developit to merge it, of course! You may wish to validate that whatever replacement you choose maintains compatibility with isomorphic-unfetch in a headless Node.js environment without extra dependencies.

After thinking on this further and looking at the files in the files in my PR, I forgot that this repo actually houses both unfetch and isomorphic-unfetch. Maybe one complication I had was that my headless server code didn't use the TypeScript DOM library so it didn't have access to that fetch definition but I did have access to node-fetch typing in both client and server? Sorry, but I can't remember the details.

from unfetch.

dawsbot avatar dawsbot commented on August 25, 2024

Same thoughts, my TypeScript build is breaking when using isomorphic-unfetch as a dependency. Even after an npm install --dev @types/node-fetch my TypeScript build is still broken.

Error: node_modules/isomorphic-unfetch/index.d.ts:7:8 - error TS7016: Could not find a declaration file for module 'node-fetch'. '/Users/dawsonbotsford/code/earn/essential-eth/node_modules/node-fetch/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`

7 } from "node-fetch";

Any thoughts on fixing this in the core package?

from unfetch.

nmemoto avatar nmemoto commented on August 25, 2024
node_modules/isomorphic-unfetch/index.d.ts:7:8 - error TS7016: Could not find a declaration file for module 'node-fetch'. '/workspace/node_modules/node-fetch/lib/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/node-fetch` if it exists or add a new declaration (.d.ts) file containing `declare module 'node-fetch';`

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

This event can probably be cured by

npm i --save-dev @types/[email protected]

from unfetch.

kaichii avatar kaichii commented on August 25, 2024

any progress?

from unfetch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.