Skip to content

Provide explicit type for Redis client #2872

Open
@golopot

Description

Motivation

When using the node-redis package in TypeScript, it's not immediately clear what the correct type for a Redis client should be. Currently, attempting to use the RedisClientType leads to type errors:

import { createClient, RedisClientType } from "redis";

function useClient(redis: RedisClientType) {}

const client = createClient();
useClient(client);
// ~~~~ type error

To work around this, many developers resort to using ReturnType to type their client instances, as discussed in this StackOverflow thread. This approach is not intuitive.

Expected Behavior

The redis package should provide a dedicated and explicit type for the Redis client that accurately reflects the return type of createClient. This would allow developers to type their Redis clients directly without resorting to workarounds.

Basic Code Example

No response

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions