GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Typescript issue: weird dependency on node-fetch in declaration file · Issue #96 · developit/unfetch

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

New issue
Copy link
New issue
Copy link
Open
Open
Typescript issue: weird dependency on node-fetch in declaration file#96
Copy link
Labels
typescript

Description

@1999
1999
opened on Oct 13, 2018
Issue body actions

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

Reacted by Andrej Kirejeŭ, Maciek Sakrejda, Dawson Botsford and Shubham Sharma

Activity

  1. 1999 commented on Oct 13, 2018

    @1999
    1999
    on Oct 13, 2018
    Author
    More actions

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

  2. niedzielski commented on Oct 13, 2018

    @niedzielski
    niedzielski
    on Oct 13, 2018
    Contributor
    More actions

    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.

  3. 1999 commented on Oct 13, 2018

    @1999
    1999
    on Oct 13, 2018
    Author
    More actions

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

  4. niedzielski commented on Oct 13, 2018

    @niedzielski
    niedzielski
    on Oct 13, 2018
    Contributor
    More actions

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

  5. 1999 commented on Oct 14, 2018

    @1999
    1999
    on Oct 14, 2018
    Author
    More actions

    Fair enough 👍

    Reacted by Chee Aun, dimojufos and Simon Siefke
  6. developit
    added
    typescript
    on Sep 29, 2020
  7. mindplay-dk commented on Aug 2, 2021

    @mindplay-dk
    mindplay-dk
    on Aug 2, 2021
    More actions

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

    Reacted by Dawson Botsford
  8. dawsbot commented on Sep 18, 2021

    @dawsbot
    dawsbot
    on Sep 18, 2021
    More actions

    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?

  9. nmemoto commented on Oct 30, 2021

    @nmemoto
    nmemoto
    on Oct 30, 2021
    More actions
    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]

  10. kaichii commented on Jan 17, 2022

    @kaichii
    kaichii
    on Jan 17, 2022
    More actions

    any progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    typescript

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.