The `Headers` type should be iterable
See original GitHub issueWorks in Chrome, Edge, and Firefox:
const headers = new Headers({a: 1, b: 2});
console.log(Object.fromEntries(headers));
In TS:
No overload matches this call. Overload 1 of 2, ‘(entries: Iterable<readonly [PropertyKey, any]>): { [k: string]: any; }’, gave the following error. Argument of type ‘Headers’ is not assignable to parameter of type ‘Iterable<readonly [PropertyKey, any]>’. Property ‘[Symbol.iterator]’ is missing in type ‘Headers’ but required in type ‘Iterable<readonly [PropertyKey, any]>’. Overload 2 of 2, ‘(entries: Iterable<readonly any[]>): any’, gave the following error. Argument of type ‘Headers’ is not assignable to parameter of type ‘Iterable<readonly any[]>’. Property ‘[Symbol.iterator]’ is missing in type ‘Headers’ but required in type ‘Iterable<readonly any[]>’.
https://developer.mozilla.org/en-US/docs/Web/API/Headers#browser_compatibility https://caniuse.com/mdn-api_headers_--iterator
Edit: While we’re on the subject, is there any reason not to add entries
, keys
, and values
?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Ahhh, so when I added
ES2019.Object
forObject.fromEntries
, I lostdom
anddom.iterable
.Thanks a lot!
dom
anddom.iterable
are included by default but not when you manually set thelib
field, that’s why 😁Anyway it seems you don’t have the issue anymore, good to hear that!