From f9c16f226512fc8a8df461e3a07e392720462165 Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Tue, 2 Jan 2024 15:55:56 +0100 Subject: [PATCH] fix(typings): fix the type of the socket#id attribute Related: https://github.com/socketio/socket.io/issues/4884 --- lib/socket.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/socket.ts b/lib/socket.ts index 8a992e10..532a7423 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -151,7 +151,7 @@ export class Socket< public readonly io: Manager; /** - * A unique identifier for the session. + * A unique identifier for the session. `undefined` when the socket is not connected. * * @example * const socket = io(); @@ -162,7 +162,7 @@ export class Socket< * console.log(socket.id); // "G5p5..." * }); */ - public id: string; + public id: string | undefined; /** * The session ID used for connection state recovery, which must not be shared (unlike {@link id}).