workers-types icon indicating copy to clipboard operation
workers-types copied to clipboard

console, AbortController and AbortSignal conflict with node types

Open samuelcolvin opened this issue 3 years ago • 3 comments

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.

samuelcolvin avatar Mar 09 '22 21:03 samuelcolvin

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:

  1. Changing our types from global to explicit exports
  2. Separating out "CF specific" types from Node/DOM types

jkup avatar Apr 15 '22 17:04 jkup

This is issue #203...

samuelcolvin avatar Apr 15 '22 18:04 samuelcolvin

@samuelcolvin 😅 sorry, I meant https://github.com/cloudflare/workers-types/issues/164 (updated my original comment too!)

jkup avatar Apr 15 '22 18:04 jkup

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. 👍

mrbbot avatar Oct 21 '22 13:10 mrbbot

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.

mrbbot avatar Jan 19 '23 17:01 mrbbot