Skip to content

5.0.0 HGETALL returns type doesn't make sens in TS #2933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oom- opened this issue May 1, 2025 · 2 comments · Fixed by #2949
Closed

5.0.0 HGETALL returns type doesn't make sens in TS #2933

oom- opened this issue May 1, 2025 · 2 comments · Fixed by #2949
Assignees
Labels

Comments

@oom-
Copy link

oom- commented May 1, 2025

Description

Since the 5.0.0 I'm having typescript error when using HGETALL

In the documentation :

Replies will be transformed into useful data structures:

await client.hGetAll("key"); // { field1: 'value1', field2: 'value2' }
await client.hVals("key"); // ['value1', 'value2']

In VS Code:

const data = await this.redisClient.HGETALL(group);
return Object.entries(data).map((entry) => {
    const value = parseFloat(entry[1]);
                             ^^^^^^^^^
    return { key: entry[0], value: isNaN(value) ? null : value };
});

Argument of type '{ toString: {}; }' is not assignable to parameter of type 'string'.
(parameter) entry: [string, {
toString: {};
}]

In 4.7.0, the TS type of the entry was:
(parameter) entry: [string, string]

@nkaradzhov nkaradzhov self-assigned this May 5, 2025
@mjjabarullah
Copy link

I am facing same issue

nkaradzhov added a commit to nkaradzhov/node-redis that referenced this issue May 7, 2025
Fix type parameter for transformTuplesReply in CONFIG_GET and HGETALL commands

fixes redis#2933
@nkaradzhov
Copy link
Collaborator

Hi @oom- , thanks for the catch. The fix should be available in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants