Skip to content

Commit

Permalink
fix(typings): pass SocketData type to custom namespaces (#4233)
Browse files Browse the repository at this point in the history
The `SocketData` type was only available on the main namespace.

Related: #4229
See also: fe8730c
  • Loading branch information
OrkhanAlikhanov authored Jan 4, 2022
1 parent 51784d0 commit f2b8de7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,13 @@ export class Server<
/**
* @private
*/
_nsps: Map<string, Namespace<ListenEvents, EmitEvents, ServerSideEvents>> =
new Map();
_nsps: Map<
string,
Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
> = new Map();
private parentNsps: Map<
ParentNspNameMatchFn,
ParentNamespace<ListenEvents, EmitEvents, ServerSideEvents>
ParentNamespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
> = new Map();
private _adapter?: AdapterConstructor;
private _serveClient: boolean;
Expand Down Expand Up @@ -197,7 +199,9 @@ export class Server<
name: string,
auth: { [key: string]: any },
fn: (
nsp: Namespace<ListenEvents, EmitEvents, ServerSideEvents> | false
nsp:
| Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
| false
) => void
): void {
if (this.parentNsps.size === 0) return fn(false);
Expand Down Expand Up @@ -579,7 +583,7 @@ export class Server<
fn?: (
socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
) => void
): Namespace<ListenEvents, EmitEvents, ServerSideEvents> {
): Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData> {
if (typeof name === "function" || name instanceof RegExp) {
const parentNsp = new ParentNamespace(this);
debug("initializing parent namespace %s", parentNsp.name);
Expand Down

0 comments on commit f2b8de7

Please sign in to comment.