ioredis
ioredis copied to clipboard
TypeScript overloads for `set` doesn't allow `NX` together with expiration tokens
For example:
redis.set('key', 'value', 'NX', 'EX', 1000);
results in:
No overload matches this call.
The last overload gave the following error.
Argument of type '"NX"' is not assignable to parameter of type '"KEEPTTL"'.
If you swap the arguments so it's redis.set('key', 'value', 'EX', 1000, 'NX');
it works, though this isn't how the redis docs describe the command https://redis.io/commands/set/ this is the definition that's causing it
set(
key: RedisKey,
value: string | Buffer | number,
secondsToken: "EX",
seconds: number | string,
nx: "NX",
callback?: Callback<"OK" | null>
): Result<"OK" | null, Context>;
https://raw.githubusercontent.com/redis/ioredis/main/lib/utils/RedisCommander.ts
I just ran into this issue as well
Yep, the only way to do it the officially documented way is to add @ts-ignore, which is really bad practice.
I just ran into this issue as well