Repository navigation
Description
Description
Several Socket.IO methods are fluent at runtime and in their public declarations, but the corresponding Smocket contracts and implementations currently return void.
This issue covers only the methods whose corresponding object is the observed return value:
Server.use();Namespace.use();- server
Socket.disconnect(); - client
Socket.connect(); - client
Socket.disconnect().
Each method should return the same server, namespace, or socket instance it was called on. Public types must preserve event maps and socket data through the returned value, and existing call sites that ignore the result must continue to compile.
Server.on() is explicitly outside this issue. Socket.IO's declaration and runtime result conflict there: the declaration says this, while the runtime call returns the root namespace. Smocket's current void compromise must not be changed as part of a general fluent-return correction.
The return identities and declarations must be verified against Socket.IO 4.7 and 4.8 before updating the contracts. If a supported version differs, the shared contract must admit the measured declarations without inventing uniformity.
Reproduction
import { connect, Server } from 'smocket';
const URL = 'http://localhost:3000';
const io = new Server(URL);
const namespace = io.of('/');
const client = connect(URL);
const socket = await io.nextConnection();
console.log(io.use((_socket, next) => next()) === io); // expected: true
console.log(namespace.use((_socket, next) => next()) === namespace); // expected: true
console.log(client.disconnect() === client); // expected: true
console.log(client.connect() === client); // expected: true
console.log(socket.disconnect() === socket); // expected: trueCompletion requires runtime identity assertions and consumer type fixtures for all five methods, including chained use with non-default event maps.
smocket version
0.4.2
Environment
Node 22, Vitest 4; Socket.IO and socket.io-client 4.8.3 reference probes and declarations, with Socket.IO 4.7 and 4.8 verification required
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity