Skip to content
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

Provide explicit type for Redis client #2872

Open
golopot opened this issue Nov 29, 2024 · 0 comments
Open

Provide explicit type for Redis client #2872

golopot opened this issue Nov 29, 2024 · 0 comments

Comments

@golopot
Copy link

golopot commented Nov 29, 2024

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

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

No branches or pull requests

1 participant