Skip to content
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

The dom.iterable lib contains many interfaces that should also be in webworker #32435

Open
philipwalton opened this issue Jul 16, 2019 · 6 comments
Assignees
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone

Comments

@philipwalton
Copy link

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: #20595

@sandersn
Copy link
Member

sandersn commented 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.

@sandersn
Copy link
Member

Same, I forgot this again. =( I'll try to get to it in a couple of weeks for 4.0.

@sandersn
Copy link
Member

sandersn commented May 6, 2020

Like #20595, the solution to this problem is to move the webworker-shared parts of dom.iterable.d.ts to web.iterable.d.ts and have both webworker.d.ts and dom.iterable.d.ts. (I'm not sure yet if it's possible to include webworker without targetting es2015, but es5 should not include web.iterable.d.ts by default).

@tankakatan
Copy link

The problem is still present in TypeScript 4.3.4 and it's really annoying. I use [email protected] in conjunction with [email protected] in my project, and it fails to compile my tests because of the issue. Please resolve.

@kangzeroo
Copy link

kangzeroo commented Jun 27, 2021

I am having this issue too, but with "lib": ["es2015", "dom", "webworker"], in my tsconfig.json (not using dom.iterable lib).

Going to try this comment's suggestion to "skipLibCheck": true, although I reckon that might end up badly in production... with the web worker, or some other lib... Will update with my findings...

UPDATE: Ok, so "skipLibCheck": true worked... I was able to compile. But I am concerned I will run into issues in production (esp with other libs). BUT if the web worker runs in its own process, perhaps the types won't ever conflict in prod? Could someone with more expertise on this matter clarify for me? 🙏 thanks!

@alexandrzavalii
Copy link

looks like the issue is still present?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Rescheduled This issue was previously scheduled to an earlier milestone
Projects
None yet
Development

No branches or pull requests

8 participants