Skip to content

Calling io.emit("event") with events that has no arguments result in TypeScript errors #4914

Closed
@lts20050703

Description

@lts20050703

Describe the bug
Calling io.emit("event") with events that either no argument result in TypeScript errors.

To Reproduce

Socket.IO server version: 4.7.3

Server

import { Server } from "socket.io";

interface ServerToClientEvents {
  noArg: () => void;
}

const io = new Server<{}, ServerToClientEvents>();

io.emit("noArg"); // <- Error

Expected behavior
No errors

Actual behavior
Argument of type 'string' is not assignable to parameter of type 'never'. ts(2345)

Platform:

  • Device: Lenovo IdeaPad 5 14ITL05
  • OS: Windows 11 Home 23H2 (22631.2861)

Additional context
Seems to be a regression, after downgrading to 4.7.2 the error disappeared.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions