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 dom.iterable lib contains many interfaces that should also be in webworker

See original GitHub issue

Many of the interfaces defined in dom.iterable should also be available to web workers. These include:

  • Headers
  • FormData
  • URLSearchParams

And since the dom.iterable library does not play well with the webworker library, I have to define these interfaces in my own, separate, library (instead of just including built-in libraries).

The webworker library should either also have an “iterable” variant, or these interfaces should be abstracted to a higher level.

TypeScript Version: 3.5.3, master

Search Terms: dom iterable worker

Code

// index.ts
const h = new Headers();

console.log([...h.entries()]);
const h = new Headers();

console.log([...h.entries()]);
tsc --target esnext --lib esnext,webworker index.ts

Expected behavior:

This should compile fine (as it does when using --lib esnext,dom,dom.iterable).

Actual behavior:

index.ts:3:19 - error TS2339: Property 'entries' does not exist on type 'Headers'.

3 console.log([...h.entries()]);
                    ~~~~~~~

Found 1 error.

Playground Link:

Can’t show this in the playground as I can’t specify --lib options.

Related Issues:

Somewhat related to: https://github.com/microsoft/TypeScript/issues/20595

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:9
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
sandersncommented, Jan 9, 2020

Unfortunately, I missed this for 3.8. I’m going to move to 3.9 and look at it early in the release cycle with @orta.

1reaction
tankakatancommented, Jun 26, 2021

The problem is still present in TypeScript 4.3.4 and it’s really annoying. I use jest@27.0.5 in conjunction with ts-jest@27.0.3 in my project, and it fails to compile my tests because of the issue. Please resolve.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Option: lib - TypeScript
Your runtime platform provides certain JavaScript API objects (maybe through polyfills), but doesn't yet support the full syntax of a given ECMAScript version ......
Read more >
TypeScript: Declare Different Libraries/References for ...
How can I have both files that need references to dom and files that need references to webworker within the same project? Here...
Read more >
lib.d.ts - TypeScript Deep Dive - Gitbook
This file contains the ambient declarations for various common JavaScript constructs present in JavaScript runtimes and the DOM.
Read more >
Worker.postMessage() - Web APIs | MDN
The postMessage() method of the Worker interface sends a message to the ... the structured clone algorithm, which includes cyclical references.
Read more >
Configuration | Manual - Deno
To use a TypeScript configuration file with Deno, you have to provide a path on ... This library will conflict with libraries like...
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