-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Calling io.emit("event") with events that has no arguments result in TypeScript errors #4914
Calling io.emit("event") with events that has no arguments result in TypeScript errors #4914
Comments
This seems to be caused by f6ef267 |
@lts20050703 - from #4813 (comment)
For emitting with ack from the server, it is correctly an error now, because it wouldn't do what you'd expect from the beginning and would timeout immediately as darrachequesne pointed out. Plus the type definition was misleading for it in 4.7.2 anyway.
I will however look into the no-callback one, since that should be valid. |
@lts20050703, PR is up with the fix for the noArgs issue. Until the fix is merged in and a new version is cut, you can use patch-package (or something similar) to update the - export declare type EventNamesWithoutAck<Map extends EventsMap, K extends EventNames<Map> = EventNames<Map>> = IfAny<Last<Parameters<Map[K]>> | Map[K], K, K extends (Last<Parameters<Map[K]>> extends (...args: any[]) => any ? never : K) ? K : never>;
+ export declare type EventNamesWithoutAck<Map extends EventsMap, K extends EventNames<Map> = EventNames<Map>> = IfAny<Last<Parameters<Map[K]>> | Map[K], K, K extends (Parameters<Map[K]> extends never[] ? K : never) ? K : K extends (Last<Parameters<Map[K]>> extends (...args: any[]) => any ? never : K) ? K : never>; I believe it would be line 32, but I don't have the current version installed anywhere to double check that line number (also, the line might not be exactly the same, but you are replacing the declaration of EventNamesWithoutAck). |
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
Expected behavior
No errors
Actual behavior
Argument of type 'string' is not assignable to parameter of type 'never'. ts(2345)
Platform:
Additional context
Seems to be a regression, after downgrading to 4.7.2 the error disappeared.
The text was updated successfully, but these errors were encountered: