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

Update socket.ts: Change the socket.data type from Partial<SocketData… #4740

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

SyedTayyabUlMazhar
Copy link
Contributor

The kind of change this PR does introduce

  • a bug fix
  • a new feature
  • an update to the documentation
  • a code change that improves performance
  • other

Current behavior

The type of socket.data is Partial. If I am passing SocketData type as {id: number, name: string}, then as I read socket.data.name I would have to use non-null assertions even though my own type implies that id would always be defined.

New behavior

Now, if someone wants to specify that a few or all of their properties might not be available at runtime, they can do so by specifying that in their own type.

Other information (e.g. related issues)

See issue 4537

SyedTayyabUlMazhar and others added 2 commits June 18, 2023 15:52
…> to SocketData

Wrapping SocketData with Partial causes issues when reading data even if you've made sure to pass all values. If someone want to make their type Partial or make only a few properties optional, they can do so in their own type instead.
@darrachequesne darrachequesne merged commit e5c62ca into socketio:main Jun 20, 2023
@darrachequesne
Copy link
Member

@SyedTayyabUlMazhar thanks!

@darrachequesne darrachequesne added this to the 4.7.0 milestone Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants