Skip to content

Commit

Permalink
fix: type of zscore result should be nullable (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
vimutti77 authored Aug 23, 2022
1 parent ddb3f89 commit a3838ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/returnTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ module.exports = {
zrevrange: "string[]",
zrevrangebyscore: "string[]",
zrevrank: "number | null",
zscore: "string",
zscore: "string | null",
zunion: "string[]",
zmscore: "(string | null)[]",
zunionstore: "number",
Expand Down
8 changes: 4 additions & 4 deletions lib/utils/RedisCommander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13854,13 +13854,13 @@ interface RedisCommander<Context extends ClientContext = { type: "default" }> {
zscore(
key: RedisKey,
member: string | Buffer | number,
callback?: Callback<string>
): Result<string, Context>;
callback?: Callback<string | null>
): Result<string | null, Context>;
zscoreBuffer(
key: RedisKey,
member: string | Buffer | number,
callback?: Callback<Buffer>
): Result<Buffer, Context>;
callback?: Callback<Buffer | null>
): Result<Buffer | null, Context>;

/**
* Add multiple sorted sets
Expand Down
4 changes: 4 additions & 0 deletions test/typing/commands.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ expectType<Promise<number>>(redis.zadd("key", "CH", 1, "member"));
expectType<Promise<string | null>>(redis.zrandmember("key"));
expectType<Promise<string[]>>(redis.zrandmember("key", 20));

// ZSCORE
expectType<Promise<string | null>>(redis.zscore("key", "member"));
expectType<Promise<Buffer | null>>(redis.zscoreBuffer("key", "member"));

// GETRANGE
expectType<Promise<Buffer>>(redis.getrangeBuffer("foo", 0, 1));

Expand Down

0 comments on commit a3838ae

Please sign in to comment.