Repository navigation
fix(sio-client/types): fix the return type of emitWithAck() with the timeout() flag - #5627
Open
mark1russell7 wants to merge 1 commit into
Open
mark1russell7 wants to merge 1 commit into
mark1russell7 wants to merge 1 commit into
Conversation
…timeout() flag FirstArg only matches a callback with one argument. With the timeout() flag, the callback gets an error as first argument, so the type of the value was any instead of the type of the acknowledgement. This uses the same approach as FirstNonErrorArg in the socket.io package. The type test in test/typed-events.test-d.ts already expects this type, but the test:types script is "exit 0" since 8bead0f, so it does not run.
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.
The kind of change this PR does introduce
Current behavior
With the
timeout()flag,emitWithAck()returnsPromise<any>.FirstArgonly matches a callback with one argument, andtimeout()adds an error as first argument of the callback.#4925 reported this. The server side was fixed in #4817 with
FirstNonErrorArg, and in #4925 the maintainer said that the same change is needed on the client side.New behavior
The client uses the same
FirstNonErrorTupleandFirstNonErrorArgtypes as the server (packages/socket.io/lib/typed-events.ts).FirstArgstays exported.test/typed-events.test-d.tsalready expectsstringfor this value, but the scripttest:typesisexit 0since 8bead0f (tsd is not upgraded for TypeScript 6), so the type tests do not run. So the check below ran withtsc(TypeScript 6.0.3,strict,module: nodenext) on a file intest/, against the build of the package:The check ran in GitHub Actions (Node.js 24.22.2 on Linux): the check with the
libfolder of upstream main (before), then with this change (after), thennpm testof socket.io-client with this change:Other information (e.g. related issues)
Related: #4925, #4817
This PR was prepared with AI assistance (Claude). The tests above were run before and after the change, with the results above.
🤖 Generated with Claude Code