Skip to content

Commit

Permalink
fix: add the missing typing for Redis#call()
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Mar 14, 2022
1 parent b530a0b commit 747dd30
Show file tree
Hide file tree
Showing 5 changed files with 5,128 additions and 10,305 deletions.
31 changes: 31 additions & 0 deletions bin/generateRedisCommander/template.ts
Expand Up @@ -20,6 +20,37 @@ export type Result<T, Context extends ClientContext> =
ResultTypes<T, Context>[Context["type"]];

interface RedisCommander<Context extends ClientContext = { type: "default" }> {
/**
* Call arbitrary commands.
*
* `redis.call('set', 'foo', 'bar')` is the same as `redis.set('foo', 'bar')`,
* so the only case you need to use this method is when the command is not
* supported by ioredis.
*
* ```ts
* redis.call('set', 'foo', 'bar');
* redis.call('get', 'foo', (err, value) => {
* // value === 'bar'
* });
* ```
*/
call(command: string, callback?: Callback<unknown>): Result<unknown, Context>;
call(
command: string,
args: (string | Buffer | number)[],
callback?: Callback<unknown>
): Result<unknown, Context>;
call(
...args: [
command: string,
...args: (string | Buffer | number)[],
callback: Callback<unknown>
]
): Result<unknown, Context>;
call(
...args: [command: string, ...args: (string | Buffer | number)[]]
): Result<unknown, Context>;

////
}

Expand Down
1 change: 0 additions & 1 deletion lib/utils/Commander.ts
Expand Up @@ -117,7 +117,6 @@ commands.forEach(function (commandName) {
);
});

// @ts-expect-error
Commander.prototype.call = generateFunction("call", "utf8");
// @ts-expect-error
Commander.prototype.callBuffer = generateFunction("callBuffer", null);
Expand Down

0 comments on commit 747dd30

Please sign in to comment.