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.

'FormData' refers to a value, but is being used as a type here

See original GitHub issue

Reproduction

Hi, I’ve got some issues with node-fetch v3.2.10 while trying to upgrade from v2.6.7 (tbf these issues appeared starting from v3.0.0).

When trying to compile typescript getting

node_modules/formdata-polyfill/esm.min.d.ts:2:11 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?

2   new (): FormData;
            ~~~~~~~~

Or

node_modules/node-fetch/@types/index.d.ts:137:22 - error TS2749: 'FormData' refers to a value, but is being used as a type here. Did you mean 'typeof FormData'?

137  formData(): Promise<FormData>;
                         ~~~~~~~~

Expected behavior

I expect not to get any issue

Your Environment

software version
node-fetch 3.2.10
node 18.1.0
yarn 3.2.0
Operating System WSL2.0 Ubuntu 20.04, Windows 10

Tried typescript v.4.7.4 and v4.8.4, both gets the same result

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

2reactions
DarkMatterMattcommented, Oct 27, 2022

This issue is likely to be a duplicate of #1617, introduced in #1287. Workarounds are to revert to v3.2.8 or add DOM to the libraries included in tsconfig.

0reactions
qtikicommented, Oct 24, 2022

well… with node 18 you’d probably not need node-fetch anyway

Yes, I am eagerly awaiting for the AWS Lambda runtime support for Node 18. In the meantime I’m thinking of reverting to an older node-fetch and using that until the runtime with native fetch is supported.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ReactJS and Typescript : refers to a value, but is being used ...
I ran across this same x refers to a value, but is being used as a type here. Did you mean 'typeof x'?...
Read more >
"refers to a value, but is being used as a type here ... - Reddit
I'm hoping to get some insight into why I'm getting this error. I have a React functional component, and in a helper function...
Read more >
Uncontrolled Components - React
In a controlled component, form data is handled by a React component. The alternative is uncontrolled components, where form data is handled by...
Read more >
Typescript support - FormData type errors persist! -
node_modules/mailgun.js/dist/index.d.ts(5,51): error TS2749: 'FormData' refers to a value, but is being used as a type here.
Read more >
typescript-cheatsheet - GitHub Pages
The cheatsheet contains references to types, classes, decorators, ... More on what class inheritance is all about just below, but here's an example;....
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