typescript issue RedisAdapter and Adapter
joergbaier opened this issue · 3 comments
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
from the lockfile
"node_modules/socket.io": {
"version": "4.6.0",
"dependencies": {
"socket.io-adapter": "~2.5.2",
},
},
"node_modules/@socket.io/redis-adapter": {
"version": "8.0.1",
"dependencies": {
"socket.io-adapter": "~2.4.0",
},
},
Should I lower the version for a while to fix this problem?
If so, how far should we lower the version?
This should be fixed by f07ff7b, included in version 8.1.0
.
Though I'm not sure about the resolution algorithm:
- with
socket.io@4.6.0
$ npm -v
8.11.0
$ npm i socket.io@4.6.0 @socket.io/redis-adapter
added 24 packages, and audited 25 packages in 2s
found 0 vulnerabilities
$ npm ls socket.io-adapter
├─┬ @socket.io/redis-adapter@8.1.0
│ └── socket.io-adapter@2.5.2
└─┬ socket.io@4.6.0
└── socket.io-adapter@2.5.2 deduped // OK
- with
socket.io@4.5.0
$ npm i socket.io@4.5.0 @socket.io/redis-adapter
added 27 packages, and audited 28 packages in 743ms
found 0 vulnerabilities
$ npm ls socket.io-adapter
tmp
├─┬ @socket.io/redis-adapter@8.1.0
│ └── socket.io-adapter@2.5.2
└─┬ socket.io@4.5.0
└── socket.io-adapter@2.4.0 // NOT OK
- with
socket.io@4.5.0
(two steps)
$ npm i socket.io@4.5.0
added 22 packages, and audited 23 packages in 700ms
found 0 vulnerabilities
$ npm i @socket.io/redis-adapter
added 3 packages, and audited 26 packages in 506ms
found 0 vulnerabilities
$ npm ls socket.io-adapter
tmp
├─┬ @socket.io/redis-adapter@8.1.0
│ └── socket.io-adapter@2.4.0
└─┬ socket.io@4.5.0
└── socket.io-adapter@2.4.0 deduped // OK
Please reopen if needed.