You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am attempting to figure out how to properly type the multi command in the v5 version of this package, and I could use some assistance.
Here is an example of something I had in the v4 version:
let multi = client.multi().mSet(mSetRequest);
for (const request of requests) {
multi = multi.pExpire(request.key, expiration);
}
const results = await multi.exec<"typed">();
return results.every((res) => res === 1 || res === "OK");
I am getting two separate typescript errors here. I understand what they are saying, but I don't understand how to resolve them.
Based on my understanding, the first line creates a RedisClientMultiCommandType where the REPLIES generic is ["OK"], because that is the valid response from the mSet command. When I am in the loop and I attempt to add the pExpire() command to the multi, I get a typescript error complaining that I cannot add pExpire because pExpire returns a number, which is not an allowed value for the REPLIES generic. For that same reason, when I attempt to resolve things in the final line, the "res === 1" part has a typescript error because, once again, a number is not a valid thing for REPLIES.
If that REPLIES generic automatically gets hard set to whatever commands are used ONLY during the initial creation of the RedisClientMultiCommandType, how are we supposed to add commands to the multi?
I tried typing the REPLIES manually during creation:
Description
I am attempting to figure out how to properly type the multi command in the v5 version of this package, and I could use some assistance.
Here is an example of something I had in the v4 version:
I am getting two separate typescript errors here. I understand what they are saying, but I don't understand how to resolve them.
Based on my understanding, the first line creates a RedisClientMultiCommandType where the REPLIES generic is ["OK"], because that is the valid response from the mSet command. When I am in the loop and I attempt to add the pExpire() command to the multi, I get a typescript error complaining that I cannot add pExpire because pExpire returns a number, which is not an allowed value for the REPLIES generic. For that same reason, when I attempt to resolve things in the final line, the "res === 1" part has a typescript error because, once again, a number is not a valid thing for REPLIES.
If that REPLIES generic automatically gets hard set to whatever commands are used ONLY during the initial creation of the RedisClientMultiCommandType, how are we supposed to add commands to the multi?
I tried typing the REPLIES manually during creation:
But that just leads to the error: "Type ["OK"] is not assignable to type ReplyUnion[] | ["OK", number]"
The text was updated successfully, but these errors were encountered: