New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[whatwg-fetch] requires ES6 target or node.d.ts but doesnt need to #11290
Comments
please send a pull request. I'll review it. |
Looks like the problem lines are these ones, defining an iterator interface for the Headers class - https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/whatwg-fetch/whatwg-fetch.d.ts#L24-L28 These methods do exist, but they're not essential to use the library, and the type they rely on doesn't exist without ES6. Anyone know of a way to make these definitions conditional on the types actually existing? Or any other nice way to handle this without breaking things for either use case? |
DefinitelyTyped/node/node.d.ts Lines 21 to 27 in ebfa2f0
We can use this pattern. |
The workaround I used for this was to install the typings for es6-promise and then add these to a miscellaneous/catch-all "extra typings" file I have around:
I wasn't able to find all of these typings shimmed out elsewhere, so I just basically exempted the whole from type checking. |
tobico:
That actually isn't really the case. If it sees that Symbol.iterator is supported (either es6 or a polyfill) then it uses those types. Otherwise it shims in the basic iterator functionality. Because of this, I think the best option is to type the iterator shim. |
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the |
the whatwg-fetch typings reference the interfaces Symbol and IterableIterator so if you target ES5 it fails to build. The fetch project it matches at https://github.com/github/fetch has built in fallbacks for the iterators and is meant to be used with ES5. So it shouldnt reference those ES6 types.
I cant use the typings as they are without including core-js or node.d.ts or targeting ES6, which is not actually required by the library itself.
The text was updated successfully, but these errors were encountered: