cloudflare / workerd

The JavaScript / Wasm runtime that powers Cloudflare Workers
https://blog.cloudflare.com/workerd-open-source-workers-runtime/
Apache License 2.0
6.28k stars 304 forks source link

Move `URL` out of `RequestInfo` to match DOM types #3121

Closed penalosa closed 6 days ago

penalosa commented 1 week ago

Fixes https://github.com/cloudflare/workerd/issues/3090

To improve the typing situation when loading dom types in the same environment as workers-types, this PR moves the URL type out of RequestInfo, in favour of e.g. fetch() referencing fetch(req: RequestInfo | URL) directly. This matches how dom types are defined.

There should be no user-observable behaviour change for users using just workers-types, but this should improve the situation if e.g. the fetch definition comes from workers-types but the RequestInfo definition comes from dom types.

petebacondarwin commented 1 week ago

I manually applied this fix (or approximately this fix 😄) to the reproduction in the issue and it appears to resolve the typings problem.