Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server emitWithAck on typed Server has "never" typing #5257

Open
mrjogo opened this issue Dec 10, 2024 · 1 comment
Open

Server emitWithAck on typed Server has "never" typing #5257

mrjogo opened this issue Dec 10, 2024 · 1 comment
Labels
to triage Waiting to be triaged by a member of the team

Comments

@mrjogo
Copy link

mrjogo commented Dec 10, 2024

Describe the bug

emitWithAck doesn't seem to be picking up types correctly, so the type variable Ev is assigned never.

To Reproduce

Socket.IO server version: 4.8.1

Server

import { Server } from "socket.io";

interface ServerToClientEvents {
  someEvent: (callback: (err: Error) => void) => void;
}
interface ClientToServerEvents {}

const io = new Server<ClientToServerEvents, ServerToClientEvents>();
io.on("connection", async (socket) => {
  // Typescript gives error "Argument of type 'string' is not assignable to parameter of type 'never'.ts(2345)"
  await socket.emitWithAck("someEvent");

  // No error
  socket.emit("someEvent", (err) => {});
});

Client

No client code necessary.

Expected behavior
No Typescript error (similar to emit behavior)

Platform:

  • Device: Macbook Air M2
  • OS: MacOS Sonoma 14.6.1

Additional context
Seems to be the same bug as mentioned in the comment #4925 (comment), but different from that issue.

@mrjogo mrjogo added the to triage Waiting to be triaged by a member of the team label Dec 10, 2024
@barroudjo
Copy link

barroudjo commented Dec 14, 2024

I have exactly the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to triage Waiting to be triaged by a member of the team
Projects
None yet
Development

No branches or pull requests

2 participants