Repository navigation
fix(types): add event overloads to Cluster interface - #2201
Merged
Merged
Conversation
Add strongly-typed on and once event overloads to interface Cluster for parity with Redis (introduced in redis#2191). This prevents event callback parameters from falling back to any. - Add listener overloads for cluster events (message, messageBuffer, smessage, smessageBuffer, +node, -node, nodeError) and ClusterStatus events. - Add tsd compile-time tests in test/typing/cluster-events.test-d.ts.
Contributor
|
Thanks, CLGTM. Let's wait for @PavelPashov for the final verdict. |
PavelPashov
approved these changes
Sep 24, 2026
PavelPashov
left a comment
Contributor
There was a problem hiding this comment.
@MingLin1995 LGTM Thank you for the contribution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds strongly-typed on and once event overloads to interface Cluster.
Background
In #2191, event listener overloads were introduced for the standalone Redis class, providing proper types for event callbacks (such as connect, ready, error, message, etc.). However, Cluster—which mixes in EventEmitter via declaration merging—still defaulted to Node.js's fallback EventEmitter.on(event: string | symbol, listener: (...args: any[]) => void), leaving callback parameters typed as any.
Changes
There are no runtime behavior changes or backward-compatibility risks.
Note
Low Risk
Declaration-only TypeScript changes and compile-time tests; no runtime or API behavior changes.
Overview
Adds strongly typed
on/onceoverloads on the mergedClusterinterface so event listeners get correct callback signatures instead of genericEventEmitteranyargs—aligned with the standaloneRedistyping from #2191.Coverage includes pub/sub (
message,messageBuffer,pmessage,smessage, etc.), cluster lifecycle (ClusterStatus), node/subscriber events (+node,-node,nodeError,refresh, …), anderror. A tsd suite (test/typing/cluster-events.test-d.ts) locks in those types at compile time.No runtime behavior changes—types and tests only.
Reviewed by Cursor Bugbot for commit 52c4b2f. Bugbot is set up for automated code reviews on this repo. Configure here.