Skip to content

Commit

Permalink
fix(typings): update return type from emit (#3843)
Browse files Browse the repository at this point in the history
```
(channel ? io.to(channel) : io).emit("stuff", message);
```

would no longer compile.

Related: #3844
  • Loading branch information
solomon23 authored and darrachequesne committed Mar 18, 2021
1 parent 5eaeffc commit 1a72ae4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/broadcast-operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class BroadcastOperator<EmitEvents extends EventsMap>
public emit<Ev extends EventNames<EmitEvents>>(
ev: Ev,
...args: EventParams<EmitEvents, Ev>
): true {
): boolean {
if (RESERVED_EVENTS.has(ev)) {
throw new Error(`"${ev}" is a reserved event name`);
}
Expand Down Expand Up @@ -276,7 +276,7 @@ export class RemoteSocket<EmitEvents extends EventsMap>
public emit<Ev extends EventNames<EmitEvents>>(
ev: Ev,
...args: EventParams<EmitEvents, Ev>
): true {
): boolean {
return this.operator.emit(ev, ...args);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class Namespace<
public emit<Ev extends EventNames<EmitEvents>>(
ev: Ev,
...args: EventParams<EmitEvents, Ev>
): true {
): boolean {
return new BroadcastOperator<EmitEvents>(this.adapter).emit(ev, ...args);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/parent-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class ParentNamespace<
public emit<Ev extends EventNames<EmitEvents>>(
ev: Ev,
...args: EventParams<EmitEvents, Ev>
): true {
): boolean {
this.children.forEach((nsp) => {
nsp.emit(ev, ...args);
});
Expand Down

0 comments on commit 1a72ae4

Please sign in to comment.