Name 'GlobalFetch' not found despite having correct TS version
P粉662614213
P粉662614213 2023-09-13 10:01:26
0
1
506

I just built a web application repository using React/TypeScript, the application works, but the deployment fails:

> build:dev
> SNOWPACK_PUBLIC_APP_ENVIRONMENT=dev snowpack build

[@snowpack/plugin-typescript] src/api/runtime.ts(130,24): error TS2304: Cannot find name 'GlobalFetch'.
[@snowpack/plugin-typescript] Error: Command failed with exit code 2: tsc --noEmit
src/api/runtime.ts(130,24): error TS2304: Cannot find name 'GlobalFetch'.

The strange thing is that the project is running on another machine, so it is not a new development and there are no source code changes. The SO answer to "GlobalFetch" says there is a problem in some 3.x versions of the type script, but I see the installed version has a higher version:

Version "4.2.3"

Any ideas on where to look for the cause?

P粉662614213
P粉662614213

reply all(1)
P粉055726146

GlobalFetch The type has been removed from the definition in TS 3.6.

Your other development environments may use older versions of TS.

You either have to

  • Downgrade your TS version
  • Delete the GlobalFetch type in the code base
  • Recreate the type using: declare type GlobalFetch = WindowOrWorkerGlobalScope
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template