refactor(client): remove type cast in cluster slots by propagating options generics - #3380
refactor(client): remove type cast in cluster slots by propagating options generics#3380Piyush0049 wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bbaa97c667
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit e704f69. Configure here.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c11eef7fd2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Description
This pull request improves type safety across the
@redis/clientcluster subsystem by resolving a maintainer technical debt comment (// TODO: find a way to avoid type casting) incluster-slots.ts.Background
Previously,
RedisClusterClientOptionsomittedkeyof ClusterCommander, which inadvertently stripped configuration options likeRESPfrom cluster option types. This forced internal node discovery incluster-slots.tsto use an unsafeas RedisClientOptions<M, F, S, RESP, {}>type cast to bypass TypeScript compiler errors.Key Changes
RedisClusterClientOptionsto exclude command execution methods while retaining configuration properties (RESP).RedisClusterClientOptionswith<M, F, S, RESP, TYPE_MAPPING>and updatedRedisClusterOptionsproperties (rootNodes,defaults) to pass generics recursively down the topology hierarchy.options as RedisClientOptionsincluster-slots.tswith a strongly typed object literalclientOptions: RedisClientOptions<M, F, S, RESP, {}>and simplified#clientOptionsDefaultswith standard TypeScript function overloads.Checklist
npm testpass with this change (including linting)?Note
Low Risk
Mostly compile-time typing; small behavioral alignment in how RESP is passed into factory-created clients and cluster node connections.
Overview
Improves type safety for cluster and standalone client factories by threading
M,F,S,RESP, andTYPE_MAPPINGthroughRedisClusterClientOptions,rootNodes,defaults, and internalcluster-slotshelpers.RedisClusterClientOptionsis now generic and omits only cluster command surface fromClusterCommander, so options likeRESPstay on node/discovery option types instead of being stripped. Topology discovery in#getShardsbuilds an explicitRedisClientOptionsobject and drops the previousas RedisClientOptionscast;#clientOptionsDefaultsgains overloads for clearer typing.Runtime wiring: standalone
RedisClient.factorymergesconfig?.RESPinto proxied client options; cluster node creation uses#clientFactory<TYPE_MAPPING>and relies on merged defaults for RESP instead of passingRESPagain on each node.RedisCluster.createforwards factory generics explicitly.Reviewed by Cursor Bugbot for commit 8c5ea72. Bugbot is set up for automated code reviews on this repo. Configure here.