★ wanayoo — archive 1999 https://github.com/developit/unfetch/issues/96Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1999 opened this issue Oct 13, 2018 · 5 comments
Open

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

1999 opened this issue Oct 13, 2018 · 5 comments
Labels

Comments

@1999
Copy link

@1999 1999 commented Oct 13, 2018

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

@1999
Copy link
Author

@1999 1999 commented Oct 13, 2018

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

@niedzielski
Copy link
Contributor

@niedzielski niedzielski commented Oct 13, 2018

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.

@1999
Copy link
Author

@1999 1999 commented Oct 13, 2018

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

@niedzielski
Copy link
Contributor

@niedzielski niedzielski commented Oct 13, 2018

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

@1999
Copy link
Author

@1999 1999 commented Oct 14, 2018

Fair enough 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.