-
Notifications
You must be signed in to change notification settings - Fork 344
TypeScript 3.6.2 removed GlobalFetch #1131
Comments
My workaround is an additional file declare type GlobalFetch = WindowOrWorkerGlobalScope This bug is fixed in 04d405a but there is still no new version in NPM repo. |
apollo-cache-inmemory ^1.6.2 → ^1.6.3 apollo-client ^2.6.3 → ^2.6.4 dotenv ^8.0.0 → ^8.1.0 graphql ^14.4.2 → ^14.5.4 @graphql-codegen/cli ^1.4.0 → ^1.6.1 @graphql-codegen/typescript ^1.4.0 → ^1.6.1 @graphql-codegen/typescript-document-nodes ^1.4.0 → ^1.6.1 @graphql-codegen/typescript-operations ^1.4.0 → ^1.6.1 @types/graphql ^14.2.2 → ^14.5.0 @types/node ^12.6.2 → ^12.7.2 markdownlint-cli ^0.17.0 → ^0.18.0 tslint ^5.18.0 → ^5.19.0 typescript ^3.5.3 → ^3.6.2
I am using apollo-client 2.6.2 in my Ionic application. It was working fine until I ran
I have been using TypeScript 3.3.333 but suddenly the build has started to fail with the 'GlobalFetch' issue. Can someone help me with a fix or workaround? It has become a showstopper for our application release. The suggested workaround does not work as in my case. |
@satishmolletipipra My guess is you forgot to use but you should be able to re-add this type as: /// <reference lib="dom" />
declare interface GlobalFetch {
fetch(input: RequestInfo, init?: RequestInit): Promise<Response>
} to your local |
I am just using TypeScript 3.5 until this gets fixed (as well as some other unrelated issues). I just set this in my package.json: |
This seems like the only way right now... |
@hwillson any chance to release this fix? |
just saw that this fix was released as 1.5.16. So i guess this issue is actually resolved. |
Compiling to js for production fails due to missing GlobalFetch. According to [this](apollographql/apollo-link#1131) issue fix is done but it's not in released. Solution is either to add type definition or to downgrade.
To clarify, that's 1.5.16 of apollo-link-http that now depends on the fixed apollo-link-http-common (which had the type error). |
Maybe this helps someone as I had problems with applying the workarounds. They didn't work for me probably because I use A workaround that did work was to set diff --git a/node_modules/apollo-boost/lib/index.d.ts b/node_modules/apollo-boost/lib/index.d.ts
index 1f58c91..9234caa 100644
--- a/node_modules/apollo-boost/lib/index.d.ts
+++ b/node_modules/apollo-boost/lib/index.d.ts
@@ -22,7 +22,7 @@ export interface PresetConfig {
uri?: string | UriFunction;
credentials?: string;
headers?: any;
- fetch?: GlobalFetch['fetch'];
+ fetch?: WindowOrWorkerGlobalScope['fetch'];
fetchOptions?: HttpLink.Options;
clientState?: ClientStateConfig;
onError?: ErrorLink.ErrorHandler;
diff --git a/node_modules/apollo-boost/src/index.ts b/node_modules/apollo-boost/src/index.ts
index c9f0751..648d1a8 100644
--- a/node_modules/apollo-boost/src/index.ts
+++ b/node_modules/apollo-boost/src/index.ts
@@ -31,7 +31,7 @@ export interface PresetConfig {
uri?: string | UriFunction;
credentials?: string;
headers?: any;
- fetch?: GlobalFetch['fetch'];
+ fetch?: WindowOrWorkerGlobalScope['fetch'];
fetchOptions?: HttpLink.Options;
clientState?: ClientStateConfig;
onError?: ErrorLink.ErrorHandler;
|
I am still seeing this issue. I can apply a patch as the ^ above mentions, but it makes me kind of nervous. Has this still not been fixed? |
GlobalFetch was removed in TS 3.6.2: apollographql/apollo-link#1131
* Update dependency typescript to v3.9.5 * Update dependency typescript to v3.9.5 * Fix name clashes in resolvers-types.ts with a hack I modified indent_style back to "space" in .editorconfig to avoid too much changes in this commit's diff. We still have the following problem: "error TS5053: Option 'noEmit' cannot be specified with option 'composite'." * Add --composite false to "typecheck:api" npm command TypeScript incremental build seems to be a problem for projects using Babel, like Next.js apps: "error TS5053: Option 'noEmit' cannot be specified with option 'composite'." So... microsoft/TypeScript#36917 * Suppress TS errors from mocked server context * Fix *Payload interfaces with a temporary hack * Fix directories in VS Code workspace config * Add --composite false to "typecheck:web" npm command * Add tsconfig.build.json to avoid incremental build For package/web, which uses Babel. * Replace GlobalFetch with WindowOrWorkerGlobalScope GlobalFetch was removed in TS 3.6.2: apollographql/apollo-link#1131 * Fix root "build" command to use tsconfig.build.json Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Josias Iquabius <iquabius@gmail.com>
I am getting errors in apollo-link-http-common when trying to build my code now since GlobalFetch no longer exists.
See the blog post on the update: https://devblogs.microsoft.com/typescript/announcing-typescript-3-6/#dom-updates
The text was updated successfully, but these errors were encountered: