The dom.iterable lib contains many interfaces that should also be in webworker
See original GitHub issueMany 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:
- Created 4 years ago
- Reactions:9
- Comments:6 (3 by maintainers)
Top GitHub Comments
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.
The problem is still present in TypeScript 4.3.4 and it’s really annoying. I use
jest@27.0.5
in conjunction withts-jest@27.0.3
in my project, and it fails to compile my tests because of the issue. Please resolve.