diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts index f8b6991e48..80a7ec66f7 100644 --- a/packages/bun-types/bun.d.ts +++ b/packages/bun-types/bun.d.ts @@ -5679,7 +5679,7 @@ declare module "bun" { * * This will apply to all sockets from the same {@link Listener}. it is per socket only for {@link Bun.connect}. */ - reload(handler: SocketHandler): void; + reload(options: Pick, "socket">): void; /** * Get the server that created this socket @@ -6022,7 +6022,7 @@ declare module "bun" { stop(closeActiveConnections?: boolean): void; ref(): void; unref(): void; - reload(options: Pick, "socket">): void; + reload(options: Pick, "socket">): void; data: Data; } interface TCPSocketListener extends SocketListener { diff --git a/test/integration/bun-types/fixture/tcp.ts b/test/integration/bun-types/fixture/tcp.ts index fe1b66a648..e8f42689a1 100644 --- a/test/integration/bun-types/fixture/tcp.ts +++ b/test/integration/bun-types/fixture/tcp.ts @@ -145,3 +145,23 @@ listener.reload({ // ...listener. }, }); + +// Test Socket.reload() type signature (issue #26290) +// The socket instance's reload() method should also accept { socket: handler } +await Bun.connect({ + data: { arg: "asdf" }, + socket: { + open(socket) { + // Socket.reload() should accept { socket: handler }, not handler directly + socket.reload({ + socket: { + open() {}, + data() {}, + }, + }); + }, + data() {}, + }, + hostname: "localhost", + port: 1, +});