lquixada / cross-fetch

Universal WHATWG Fetch API for Node, Browsers and React Native.
MIT License
1.66k stars 102 forks source link

Question: does global declaration need to be kept #172

Open Moumouls opened 10 months ago

Moumouls commented 10 months ago

Hello,

We have recently upgraded to the latest version (4.X) of the graphql-request package. Additionally, we are utilizing an older version of GraphQL Yoga v2.

During this process, we encountered a type conflict error. This was due to an older version of @whatwg-node/fetch that declared the same global as this package.

declare const _fetch: typeof fetch;
declare const _Request: typeof Request;
declare const _Response: typeof Response;
declare const _Headers: typeof Headers;
declare const _FormData: typeof FormData;
declare const _AbortController: typeof AbortController;
declare const _ReadableStream: typeof ReadableStream;
declare const _WritableStream: typeof WritableStream;
declare const _TransformStream: typeof TransformStream;
declare const _Blob: typeof Blob;
declare const _File: typeof File;
declare const _crypto: typeof crypto;
declare const _btoa: typeof btoa;
declare const _TextEncoder: typeof TextEncoder;
declare const _TextDecoder: typeof TextDecoder;
declare const _Event: typeof Event;
declare const _EventTarget: typeof EventTarget;

Fortunately, we noticed that in the newer version of @whatwg-node/fetch, they have removed the global declaration. This change helps avoid conflicts with this library. However, I'm wondering if it might be a good idea for this library to also remove the global declaration to prevent potential conflicts with other libraries.