jcayzacJ
Deno3y ago
3 replies
jcayzac

Abort signals and node compatibility

Deno and Node's AbortSignal types are not compatible. I have verified that I can use a deno AbortSignal with the node:events APIs (at least EventEmitter.once(), but I have to cast them to Node's own type if I want to get rid of errors:

export { EventEmitter } from 'node:events'
export type { AbortSignal as NodeAbortSignal } from 'npm:@types/node'

// …then cast any signal to `signal as NodeAbortSignal`.

Without the cast, I get the error below.

Is there a better/cleaner way?
Thanks.
Screenshot_2024-01-05_at_15.40.32.png
Was this page helpful?