Skip to content

typescript issue RedisAdapter and Adapter #487

@joergbaier

Description

@joergbaier

The following typescript issue came up the last time we tried updating our packages as well. Last time this was fixed by redis-adapter 8.0.1. It seems like socketio and the adapter aren't being released in sync.

socket.io 4.6.0
@socket.io/redis-adapter 8.0.1
typescript 4.9.5

error TS2769: No overload matches this call.
  Overload 1 of 3, '(srv?: number | import("http").Server<...> | Http2SecureServer | import("https").Server<...>, opts?: Partial<...>): Server<...>', gave the following error.
    Type '(nsp: any) => RedisAdapter' is not assignable to type 'AdapterConstructor'.
      Type '(nsp: any) => RedisAdapter' is not assignable to type '(nsp: Namespace<DefaultEventsMap, DefaultEventsMap, DefaultEventsMap, any>) => Adapter'.
        Type 'RedisAdapter' is missing the following properties from type 'Adapter': _encode, persistSession, restoreSession
  Overload 2 of 3, '(srv: number | import("http").Server<...> | Partial<ServerOptions> | Http2SecureServer | import("https").Server<...>, opts?: Partial<...>): Server<...>', gave the following error.
    Type '(nsp: any) => RedisAdapter' is not assignable to type 'AdapterConstructor'.

42     adapter: createAdapter(pubClient, subClient),
       ~~~~~~~

  node_modules/socket.io/dist/index.d.ts:35:5
    35     adapter: AdapterConstructor;
           ~~~~~~~
    The expected type comes from property 'adapter' which is declared here on type 'Partial<ServerOptions>'
  node_modules/socket.io/dist/index.d.ts:35:5
    35     adapter: AdapterConstructor;
           ~~~~~~~
    The expected type comes from property 'adapter' which is declared here on type 'Partial<ServerOptions>'

socket.io type is coming from
node_modules/socket.io/node_modules/socket.io-adapter/dist/index.d.ts - class Adapter

@socket.io/redis-adapter type is coming from
node_modules/socket.io-adapter/dist/index.d.ts - class Adapter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions