fix(socket.io-client): export reserved-events types to fix ts(4023) on declaration emit - #5533
Closed
SnowingFox wants to merge 1 commit into
Closed
SnowingFox wants to merge 1 commit into
SnowingFox wants to merge 1 commit into
Conversation
…n declaration emit Fixes socketio#5307
darrachequesne
pushed a commit
that referenced
this pull request
Sep 11, 2026
Export reserved event and related option interfaces from the client packages so that declaration emit can name inferred public types. This fixes TS4023 errors when consumers export values derived from typed emitter methods, such as `socket.io.listeners`. Related: #5307
darrachequesne
pushed a commit
that referenced
this pull request
Sep 11, 2026
Export reserved event and related option interfaces from the client packages so that declaration emit can name inferred public types. This fixes TS4023 errors when consumers export values derived from typed emitter methods, such as `socket.io.listeners`. Related: #5307
Member
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.
Description
Fixes #5307.
When a downstream consumer re-exports a value whose (inferred) type references
socket.io-client'sSocket/Managertypes, TypeScript's declaration emitter must be able to name the "reserved events" maps those classes are parameterized with. Those maps were not exported, so anytsc --declarationpass over such a consumer failed with:As diagnosed in the issue discussion, the failing names (
SocketReservedEvents,ManagerReservedEvents,HandshakeData,WriteOptions,TransportReservedEvents,Cookie) are all unexported interfaces.Changes
Type-only additions (no runtime behaviour change):
packages/socket.io-client/lib/socket.ts: exportSocketReservedEventspackages/socket.io-client/lib/manager.ts: exportManagerReservedEventspackages/engine.io-client/lib/socket.ts: exportSocketReservedEvents,HandshakeData,WriteOptionspackages/engine.io-client/lib/transport.ts: exportTransportReservedEventspackages/engine.io-client/lib/globals.node.ts: exportCookie(referenced by the exportedparse/CookieJar)lib/index.ts, following the pattern used forDisconnectDescriptionin Export DisconnectDescription type directly from 'socket.io-client' #5392Test
Added a declaration-emit regression fixture at
packages/socket.io-client/test/types/ts4023.test.tsthat mirrors the issue's reproducer (an exported value whose inferred type references the reserved-events maps ofSocket,Manager, the Engine.IOSocketand itsTransport). Onmainit fails with the exact ts(4023) errors reported in the issue:After the fix, the same command exits cleanly (verified with the TypeScript version pinned in this repo,
^6.0.3).Related
DisconnectDescriptionin the same manner and was merged.