ioredis icon indicating copy to clipboard operation
ioredis copied to clipboard

How to use psubscribe with ioredis 5 from typescript

Open JanFellner opened this issue 3 years ago • 2 comments

Just did a short check whether it is possible to migrate to ioredis 5 and i completely fail in using psubscribe from typescript.

I have no clue what ioredis expects here: psubscribe(...args: [...patterns: string[]]): Result<unknown, Context>;

The @types implementation of ioredis states: psubscribe(...patterns: string[]): Pipeline;

Which was fullfilled by simply calling the function with a "string" obj.psubscribe("mypattern");

Am i missing something?

JanFellner avatar Mar 29 '22 13:03 JanFellner

Hey @JanFellner 👋

...args: [...patterns: string[]] is actually the same as ...patterns: string[] so you can continue using obj.psubscribe("mypattern").

The typing seems unnecessarily complex though. We should change it to ...patterns: string[].

luin avatar Mar 29 '22 13:03 luin

Hey @luin, thanks for the quick response. Yeah typing here could be simplified (trivial though :))

JanFellner avatar Mar 29 '22 14:03 JanFellner