Repository navigation
fix(types): add smessage and smessageBuffer event overloads - #2191
Merged
Merged
Conversation
DataHandler emits smessage and smessageBuffer for sharded pub/sub, but the on/once overloads on Redis only covered message, messageBuffer, pmessage and pmessageBuffer, so both callback parameters came through as any. Add the two overload pairs with assertions for both parameter types, and rename events.test-.ts to match the surrounding files. Closes redis#2190
PavelPashov
approved these changes
Sep 10, 2026
PavelPashov
left a comment
Contributor
There was a problem hiding this comment.
Looks good, thank you for the contribution.
PavelPashov
pushed a commit
that referenced
this pull request
Sep 24, 2026
Add strongly-typed on and once event overloads to interface Cluster for parity with Redis (introduced in #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.
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.
Closes #2190.
Adds
smessageandsmessageBufferoverloads foronandonce, withassertions for both callback parameter types.
Without the overloads
npm run test:tsdreports 8 errors of the form"not identical to argument type
any"; with them it passes.Also renames
events.test-.tstoevents.test-d.tsfor consistency with theother files in that directory — as you noted, tsd already collects it, so this
activates nothing.
Note
Low Risk
Type-only changes and typing tests; no runtime subscriber or emit behavior is modified.
Overview
Adds TypeScript event overloads on
Redisforon/oncewhen listening tosmessageandsmessageBuffer, matching the existingmessage/pmessagepatterns (string vsBufferchannel and payload).Extends
test/typing/events.test-d.tswithtsdassertions so subscriber callbacks for those events are typed asstringorBufferinstead of falling through toanyand failingtest:tsd.Reviewed by Cursor Bugbot for commit ba9d3c7. Bugbot is set up for automated code reviews on this repo. Configure here.