Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
KleaTech opened this issue Nov 29, 2023 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@KleaTech
Copy link

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.

@KleaTech KleaTech added the to triage Waiting to be triaged by a member of the team label Nov 29, 2023
darrachequesne added a commit to socketio/socket.io-client that referenced this issue Jan 2, 2024
@darrachequesne
Copy link
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! 👍

@darrachequesne darrachequesne added bug Something isn't working and removed to triage Waiting to be triaged by a member of the team labels Jan 12, 2024
@darrachequesne darrachequesne added this to the 4.7.3 milestone Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants