question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The `Headers` type should be iterable

See original GitHub issue

Works 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
glen-84commented, Jul 17, 2021

Ahhh, so when I added ES2019.Object for Object.fromEntries, I lost dom and dom.iterable.

Thanks a lot!

0reactions
saschanazcommented, Jul 17, 2021

dom and dom.iterable are included by default but not when you manually set the lib field, that’s why 😁

Anyway it seems you don’t have the issue anymore, good to hear that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Campaign Variation Types - Iterable Support Center
Creating campaign variations to test in Iterable can be a fun and creative process. It's where you surface the details you want to...
Read more >
Headers.entries() - Web APIs - MDN Web Docs
The Headers.entries() method returns an iterator allowing to go through all key/value pairs contained in this object.
Read more >
Getting all headers, mismatch between the specs and polyfill ...
the fetch spec says the Headers object is iterable itself (so it should have a Symbol.iterator function). and then the polyfill has forEach....
Read more >
javascript - How do I use the `Headers` iterator in the browser?
I receive the TypeScript error: Property 'value' does not exist on type 'IterableIterator<[string, string]>'.
Read more >
Headers (kafka 2.1.0 API)
Iterable <Header> ... Modifier and Type, Method and Description. Headers ... Adds a header (key inside), to the end, returning if the operation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found