workers-types
workers-types copied to clipboard
console, AbortController and AbortSignal conflict with node types
See https://github.com/samuelcolvin/edge-mock/pull/14 I'm trying to upgrade edge-mock (implementations of worker-types types for use when testing) to supprot worker-types 3. However I'm having problem because a small number of types conflict with @types/node.
It would be wonderful if console, AbortController and AbortSignal could somehow be optional - is there some way to doing this in typescript?
Currently, until a fix for https://github.com/microsoft/TypeScript/issues/37053 is provided I don't know of any way to work around this issie.
See this build for details on the error.
Any help would be much appreicated.
I think this is the same problem as https://github.com/cloudflare/workers-types/issues/164
I think we can fix it without a TS change by either:
- Changing our types from global to explicit exports
- Separating out "CF specific" types from Node/DOM types
This is issue #203...
@samuelcolvin 😅 sorry, I meant https://github.com/cloudflare/workers-types/issues/164 (updated my original comment too!)
Hey! 👋 Thanks for reporting this, we're actively thinking about ways of fixing this in the next major version of workers-types using the new type generation system. 👍
Hey! 👋 As of @cloudflare/workers-types@4, you can selectively import type { ... } from "@cloudflare/workers-types". It's unlikely @cloudflare/workers-types and @types/node will be compatible in the near future. If you have a project that uses both these runtimes (e.g. for testing), you'll probably need to create separate tsconfig.jsons for the subsets of your files that should be typed under each set of definitions.