From f2b8de71919e1b4d3e57f15a459972c1d1064787 Mon Sep 17 00:00:00 2001 From: Orkhan Alikhanov Date: Tue, 4 Jan 2022 12:09:42 +0400 Subject: [PATCH] fix(typings): pass `SocketData` type to custom namespaces (#4233) The `SocketData` type was only available on the main namespace. Related: https://github.com/socketio/socket.io/issues/4229 See also: https://github.com/socketio/socket.io/commit/fe8730ca0f15bc92d5de81cf934c89c76d6af329 --- lib/index.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/index.ts b/lib/index.ts index 73d70f1cf8..c1cb8b12de 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -112,11 +112,13 @@ export class Server< /** * @private */ - _nsps: Map> = - new Map(); + _nsps: Map< + string, + Namespace + > = new Map(); private parentNsps: Map< ParentNspNameMatchFn, - ParentNamespace + ParentNamespace > = new Map(); private _adapter?: AdapterConstructor; private _serveClient: boolean; @@ -197,7 +199,9 @@ export class Server< name: string, auth: { [key: string]: any }, fn: ( - nsp: Namespace | false + nsp: + | Namespace + | false ) => void ): void { if (this.parentNsps.size === 0) return fn(false); @@ -579,7 +583,7 @@ export class Server< fn?: ( socket: Socket ) => void - ): Namespace { + ): Namespace { if (typeof name === "function" || name instanceof RegExp) { const parentNsp = new ParentNamespace(this); debug("initializing parent namespace %s", parentNsp.name);