Skip to content

Commit

Permalink
refactor(typings): add types for io.engine (#4591)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
LeoDog896 authored Jan 11, 2023
1 parent 727d685 commit 6652a3f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
EventNames,
} from "./typed-events";
import { patchAdapter, restoreAdapter, serveFile } from "./uws";
import type { BaseServer } from "engine.io/build/server";

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

Expand Down Expand Up @@ -127,7 +128,7 @@ export class Server<
* const clientsCount = io.engine.clientsCount;
*
*/
public engine: any;
public engine: BaseServer;

/** @private */
readonly _parser: typeof parser;
Expand Down Expand Up @@ -582,10 +583,10 @@ export class Server<
/**
* Binds socket.io to an engine.io instance.
*
* @param {engine.Server} engine engine.io (or compatible) server
* @param engine engine.io (or compatible) server
* @return self
*/
public bind(engine): this {
public bind(engine: BaseServer): this {
this.engine = engine;
this.engine.on("connection", this.onconnection.bind(this));
return this;
Expand Down

0 comments on commit 6652a3f

Please sign in to comment.