0

I am fresh building a web app repository using React/TypeScript and the app works but 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'.

Weird is the project is working on another machine, so it is not a new development, there were no source code change. SO answers on "GlobalFetch" say there was a problem with it in some 3.x version of type script, but I see the version installed has higher one:

version "4.2.3"

Any ideas on where to look for a reason?

Andy Victors
  • 335
  • 2
  • 9

1 Answers1

0

The GlobalFetch type was removed from the definitions in TS 3.6.

Your other dev environment probably uses an old version of TS.

You either have to

  • downgrade your TS version
  • remove the GlobalFetch type in your code base
  • recreate the type with: declare type GlobalFetch = WindowOrWorkerGlobalScope
Matthieu Riegler
  • 31,918
  • 20
  • 95
  • 134