-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
I was working with socket.data and noticed that I couldn't define its types. I tried to search the same issue here, but didn't find
Describe the solution you'd like
- For example I want to do
socket.data<User> - or maybe pass it when server is being created:
new Server<{user: User}>(server, { cors: { origin: * }, })- Or maybe inherit types from usage
socket.data = userthensocket.databecomessocket.data: {User, ...any}or something like this
Describe alternatives you've considered
Right now I can create a subclass to use it:
interface SocketDataType = { user: User }
export declare class ExtendedSocketServer<ListenEvents extends EventsMap = DefaultEventsMap, EmitEvents extends EventsMap = ListenEvents, ServerSideEvents extends EventsMap = DefaultEventsMap, SocketDataType = any> extends Server<ListenEvents, EmitEvents, ServerSideEvents> {
of(name: string | RegExp | ParentNspNameMatchFn, fn?: (socket: ExtendedSocketServer<ListenEvents, EmitEvents, ServerSideEvents, SocketDataType>) => void): Namespace<ListenEvents, EmitEvents, ServerSideEvents>;
}Additional context
Also, I can use the patch-package. I just modified the original node_modules/socket.io/dist/socket.d.ts and run yarn patch-package
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request