lquixada / cross-fetch

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

fix: avoid polluting global namespace in index.d.ts #158

Closed Rugvip closed 1 year ago

Rugvip commented 1 year ago

The top-level declarations of _fetch etc. pollute the global namespace, potentially causing conflicts with other libraries. This switches the type declarations to access the desired values through the global object instead.

As far as I can tell this should not cause any issues, although I'm lacking context on why the types are declared the way they are to begin with.

Rugvip commented 1 year ago

Gonna assume that the test failures are unrelated, let me know if that's not the case

wKich commented 1 year ago

I think they declared types in the global intentionally, because the library can be used as a polyfill.

wKich commented 1 year ago

And... no response.

Rugvip commented 1 year ago

Fixed in whatwg-node instead, although it still makes sense to make this change. Gonna close this and leave that for someone else though.