Skip to content

Commit 6652a3f

Browse files
authored
refactor(typings): add types for io.engine (#4591)
This adds typings for the socket.io engine field, which offers better IntelliSense when retrieving the server, as well as more confidence on the developer-side of what types of fields are entering the server. Related: #4590
1 parent 727d685 commit 6652a3f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
EventNames,
3232
} from "./typed-events";
3333
import { patchAdapter, restoreAdapter, serveFile } from "./uws";
34+
import type { BaseServer } from "engine.io/build/server";
3435

3536
const debug = debugModule("socket.io:server");
3637

@@ -127,7 +128,7 @@ export class Server<
127128
* const clientsCount = io.engine.clientsCount;
128129
*
129130
*/
130-
public engine: any;
131+
public engine: BaseServer;
131132

132133
/** @private */
133134
readonly _parser: typeof parser;
@@ -582,10 +583,10 @@ export class Server<
582583
/**
583584
* Binds socket.io to an engine.io instance.
584585
*
585-
* @param {engine.Server} engine engine.io (or compatible) server
586+
* @param engine engine.io (or compatible) server
586587
* @return self
587588
*/
588-
public bind(engine): this {
589+
public bind(engine: BaseServer): this {
589590
this.engine = engine;
590591
this.engine.on("connection", this.onconnection.bind(this));
591592
return this;

0 commit comments

Comments
 (0)