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?
The
GlobalFetchtype was removed from the definitions in TS 3.6.Your other dev environment probably uses an old version of TS.
You either have to
GlobalFetchtype in your code basedeclare type GlobalFetch = WindowOrWorkerGlobalScope