Skip to content

socket.id can be undefined according to the docs, but cannot according to the type #4884

Closed

Description

@KleaTech

Describe the bug
socket.id can be undefined according to the documentation (until connect event is triggered). But the Socket type does not mark it as possibly undefined.

To Reproduce
Check the documentation:
image
Check the code:

public readonly id: SocketId;

And:
https://github.com/socketio/socket.io-adapter/blob/28f60b880ad04ff4b48ade0cd529f1970643604f/lib/index.ts#L10

Socket.IO client version: 4.7.2

Expected behavior
Either the Socket or SocketId type should allow undefined values or the documentation should be clarified.

Activity

  1. added
    to triage
    on Nov 29, 2023
  2. darrachequesne commented on Jan 12, 2024

    @darrachequesne
    Member

    The id attribute on the client side is now typed as string | undefined: socketio/socket.io-client@f9c16f2

    On the server side, it cannot be undefined:

    public readonly id: SocketId;

    Thanks for the heads-up! 👍

  3. added
    bug
    and removed
    to triage
    on Jan 12, 2024
  4. added this to the 4.7.3 milestone on Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions