TS does not know about the existence of the window.fetch?
window.fetch(...)
error TS2304: Cannot find name 'fetch'.
Fetch is only just coming to Edge 14. The tool located at Microsoft/TSJS-lib-generator is what deals with generating the library off of Edge with certain modifications and overrides. That then is what is checked into TypeScript.
PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.
if you do not mind, we would like to keep this issue open until it is fixed.
I've used whatwg-fetch typings https://github.com/alm-tools/alm/blob/c7d31e48864a96379fabe27d1bb507ccce3e9319/src/typings.json#L28 with both https://github.com/github/fetch and https://www.npmjs.com/package/node-fetch :rose:
@basarat Correct there is a fetch.d.ts that works quite well.
One thing to consider is that fetch relies on a Promise. So using target=ES5 will complain about Promise missing:
error TS2304: Cannot find name 'Promise'.
Are there different versions of lib.d.ts depending on the target param? If so, then fetch should only be added to ES6 target.
Any updates on this? Thanks
It is open as accepting PR with a Milestone of the community (noted by the labels and milestone on the right of the issue), which is an indication that the core TypeScript do not currently have the resources to address this as a priority, but anyone in the community is more than welcome to contribute it.
Duplicate of #4948
Any updates on this? I am unable to find a working fetch dts file, am i missing something?
@mhgamework In the latest TypeScript, fetch is available with --lib dom.