You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After diving into worker-types with #1383, I realized that many of the workers-types are just modified from TS lib. Is there a reason for this? Why not extend pre-existing classes where needed?
This would add a ton of reusability and compatibility to the types since the only code is changes from built-in classes. The following classes can use this approach:
DOMException
WorkerGlobalScope
WorkerGlobalScopeEventMap
Console
console
BufferSource
WebAssembly
ServiceWorkerGlobalScope
addEventListener
removeEventListener
dispatchEvent
btoa
atob
setTimeout
clearTimeout
setInterval
queueMicrotask
structuredClone
fetch
...
I won't bother to list the 250+ symbols which only redeclare ones already present in TS lib, with little to no change.
The text was updated successfully, but these errors were encountered:
This is intentional. The types for @cloudflare/workers-types are generated directly from the workers runtime implementation, and so accurately match runtime behaviour. In most cases we're pretty close to spec-compliant with web standards, and so are similar to lib.dom.d.ts, but we recommend using @cloudflare/workers-types exclusively, and not typing your codebase against lib.dom.d.ts.
After diving into worker-types with #1383, I realized that many of the
workers-types
are just modified from TS lib. Is there a reason for this? Why notextend
pre-existing classes where needed?For example, instead of re-declaring
Body
:worker-types
currently:lib.dom.d.ts
(comments removed):Updated:
worker-types/alias.d.ts
worker-types/index.d.ts
This would add a ton of reusability and compatibility to the types since the only code is changes from built-in classes. The following classes can use this approach:
I won't bother to list the 250+ symbols which only redeclare ones already present in TS lib, with little to no change.
The text was updated successfully, but these errors were encountered: