Skip to content

Commit

Permalink
fix: remove the Partial modifier from the socket.data type (#4740)
Browse files Browse the repository at this point in the history
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.

Related: #4537
  • Loading branch information
SyedTayyabUlMazhar authored Jun 20, 2023
1 parent 01d3762 commit e5c62ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export class Socket<
* Additional information that can be attached to the Socket instance and which will be used in the
* {@link Server.fetchSockets()} method.
*/
public data: Partial<SocketData> = {};
public data: SocketData = {} as SocketData;
/**
* Whether the socket is currently connected or not.
*
Expand Down Expand Up @@ -260,7 +260,7 @@ export class Socket<
this.id = previousSession.sid;
this.pid = previousSession.pid;
previousSession.rooms.forEach((room) => this.join(room));
this.data = previousSession.data as Partial<SocketData>;
this.data = previousSession.data as SocketData;
previousSession.missedPackets.forEach((packet) => {
this.packet({
type: PacketType.EVENT,
Expand Down

0 comments on commit e5c62ca

Please sign in to comment.