search

Home  >  Q&A  >  body text

Name 'GlobalFetch' not found despite having correct TS version

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粉662614213P粉662614213427 days ago492

reply all(1)I'll reply

  • P粉055726146

    P粉0557261462023-09-14 09:15:30

    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

    reply
    0
  • Cancelreply