WebSocket client in Activity

Is there an example / is it possible to use a Websocket client inside of an activity using the typescript SDK?

The below code compiles when not being loaded as an activity by the worker. But I get Property 'dispatchEvent' is missing in type import when Webpack tries to compile it for the bundle.

lib/service/comfy/src/server/client.ts(16,5): error TS2322: Type 'typeof WebSocket' is not assignable to type '{ new (url: string | URL, protocols?: string | string[] | undefined): WebSocket; prototype: WebSocket; readonly CONNECTING: 0; readonly OPEN: 1; readonly CLOSING: 2; readonly CLOSED: 3; }'.
  Types of property 'prototype' are incompatible.
    Property 'dispatchEvent' is missing in type 'import("/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/@types+ws@8.5.10/node_modules/@types/ws/index")' but required in type 'WebSocket'.

    at createTSError (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at require.extensions.<computed> (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/ts-node@10.9.2_@swc+core@1.3.107_@types+node@18.19.14_typescript@5.4.5/node_modules/ts-node/src/index.ts:1621:12)
    at Object.newLoader [as .ts] (/Users/jelling/dev/rbt/rbt-nx/node_modules/.pnpm/pirates@4.0.6/node_modules/pirates/lib/index.js:121:7)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12) {
  diagnosticCodes: [ 2322 ]
}