Replace socket.io-client imports with a local type shim in echo.d.ts#529
Merged
taylorotwell merged 2 commits intoJun 24, 2026
Merged
Conversation
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.
Since v2.3.7, the compiled
dist/echo.d.tsunconditionally importsSocketandiofromsocket.io-client. Users who only use Reverb or Pusher never install that package, so TypeScript fails on those imports whenskipLibCheckisfalse.The root cause is that
socketio-channel.tsandsocketio-connector.tsimport fromsocket.io-client, andvite-plugin-dts(withrollupTypes: true) inlines those module references into the rolled-up declaration file.This PR adds a minimal local type shim (
src/socketio-types.ts) that declares the small subset of Socket.io types Laravel Echo actually uses —SocketIoSocket,SocketIoManager, andSocketIoFunction. The two connector/channel files andtypings/window.d.tsare updated to import from the shim instead of fromsocket.io-client. The real socket.io-client types satisfy these interfaces, so nothing changes for users who do have the package installed.After this change,
dist/echo.d.tsno longer contains anyimport … from 'socket.io-client'line. Verified by temporarily removing the package fromnode_modulesand runningtsc --noEmit— no errors. All existing tests still pass.Fixes #528