Skip to content

feat: export the contract types for the substitution path - #179

Merged
electrohyun merged 1 commit into
mainfrom
feat/export-contract-types
Aug 7, 2026
Merged

electrohyun merged 1 commit into
mainfrom
feat/export-contract-types

Conversation

@electrohyun

Copy link
Copy Markdown
Owner

Summary

An app that swaps socket.io-client for smocket via resolve.alias or vi.mock got
the value side of the substitution and lost the type side. io(url) resolved, but
src/index.ts exported only configuration types, so there was no name to annotate the
result with. This is stage 1 of #178 and stands on its own, independent of #171.

ServerContract, ServerSocketContract, ClientSocketContract, NamespaceContract,
and Handshake are now exported. They reach nine more types through their own members
(BroadcastContract, TimeoutBroadcastContract, TimeoutEmitterContract,
SocketTimeoutContract, VolatileServerSocket, VolatileClientSocket,
AdapterContract, ConnectionMiddleware, MiddlewareError), which already appear in
the emitted declarations, so those are exported too rather than left reachable but
unnameable. ConnectedClient and ServerContext stay unexported, being the dual-run
test setup's shape rather than an app-facing surface.

Additive, with no change to the exports map, so existing call sites keep compiling.
That is category 7 under 0019, a minor. Stage 2 of #178, the Socket name and subpath
exports, is not here: one package cannot give that name to both the server and the
client socket, and the design question comes first.

The new test annotates every exported type the way an app would. The annotations are
the assertion, since a missing export stops pnpm typecheck compiling.

Related issue

Refs #178

Checklist

  • Tests added or updated
  • Behavior verified against real socket.io

An app that swapped socket.io-client for smocket got the value side of
the substitution and lost the type side: `io(url)` resolved, but there
was no name to annotate the result with, since the only exported types
were configuration ones. So the swap preserved behaviour and dropped
types.

The five entry points reach nine more through their own members, and
those names already appear in the emitted declarations, so they are
exported rather than left reachable but unnameable. `ConnectedClient`
and `ServerContext` stay unexported, being the dual-run test setup's
shape and not an app-facing surface.

Whether any of these is also aliased to socket.io's own `Socket` name is
left open. One package cannot give that name to both the server and the
client socket, and supporting both directions needs subpath exports.

Refs #178
@electrohyun electrohyun added the enhancement New feature or request label Aug 7, 2026
@electrohyun electrohyun self-assigned this Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Public contract exports

Layer / File(s) Summary
Export contract types
src/index.ts
src/index.ts documents and exports additional adapter, broadcast, socket, middleware, handshake, namespace, timeout, and volatile socket types.
Validate exported types
src/index.test.ts
Tests import the exported types and verify their use through socket APIs and client/server connection behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: exporting contract types for the substitution path.
Description check ✅ Passed The description explains the substitution use case, exported types, scope, compatibility, tests, and deferred work.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@electrohyun
electrohyun marked this pull request as draft August 7, 2026 08:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/index.test.ts`:
- Around line 49-52: In the connection setup around Server.nextConnection and
io, create and store the nextConnection() promise before invoking
io('http://localhost'), then await that stored promise for serverSocket.
Preserve the existing server and client contract assignments.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 27df4b29-11fb-49e2-bd59-b1f0dc5c9891

📥 Commits

Reviewing files that changed from the base of the PR and between 4793508 and e8c57be.

📒 Files selected for processing (2)
  • src/index.test.ts
  • src/index.ts

Comment thread src/index.test.ts Resolved
@electrohyun
electrohyun marked this pull request as ready for review August 7, 2026 08:29
@electrohyun
electrohyun merged commit e1b6d94 into main Aug 7, 2026
13 checks passed
@electrohyun
electrohyun deleted the feat/export-contract-types branch August 7, 2026 08:44
@electrohyun electrohyun mentioned this pull request Aug 7, 2026
2 tasks done
@electrohyun electrohyun added the 📏 m Pull request changes 50–199 lines label Aug 11, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in smocket Aug 27, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in smocket Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 📏 m Pull request changes 50–199 lines

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant