Skip to content

Commit 61c80e6

Browse files
Change return type of _throwNoPayloadError to never
This informs the compiler that the function throws.
1 parent 3d1535a commit 61c80e6

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

src/plugins/liveobjects/livecounter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ export class LiveCounter extends LiveObject<LiveCounterData, LiveCounterUpdate>
137137
case ObjectOperationAction.COUNTER_INC:
138138
if (this._client.Utils.isNil(op.counterOp)) {
139139
this._throwNoPayloadError(op);
140-
// leave an explicit return here, so that TS knows that update object is always set after the switch statement.
141-
return;
142140
} else {
143141
update = this._applyCounterInc(op.counterOp, msg);
144142
}
@@ -263,7 +261,7 @@ export class LiveCounter extends LiveObject<LiveCounterData, LiveCounterUpdate>
263261
};
264262
}
265263

266-
private _throwNoPayloadError(op: ObjectOperation<ObjectData>): void {
264+
private _throwNoPayloadError(op: ObjectOperation<ObjectData>): never {
267265
throw new this._client.ErrorInfo(
268266
`No payload found for ${op.action} op for LiveCounter objectId=${this.getObjectId()}`,
269267
92000,

src/plugins/liveobjects/livemap.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,6 @@ export class LiveMap<T extends Record<string, Value> = Record<string, Value>>
334334
case ObjectOperationAction.MAP_SET:
335335
if (this._client.Utils.isNil(op.mapOp)) {
336336
this._throwNoPayloadError(op);
337-
// leave an explicit return here, so that TS knows that update object is always set after the switch statement.
338-
return;
339337
} else {
340338
update = this._applyMapSet(op.mapOp, opSerial, msg);
341339
}
@@ -344,8 +342,6 @@ export class LiveMap<T extends Record<string, Value> = Record<string, Value>>
344342
case ObjectOperationAction.MAP_REMOVE:
345343
if (this._client.Utils.isNil(op.mapOp)) {
346344
this._throwNoPayloadError(op);
347-
// leave an explicit return here, so that TS knows that update object is always set after the switch statement.
348-
return;
349345
} else {
350346
update = this._applyMapRemove(op.mapOp, opSerial, msg.serialTimestamp, msg);
351347
}
@@ -683,7 +679,7 @@ export class LiveMap<T extends Record<string, Value> = Record<string, Value>>
683679
return aggregatedUpdate;
684680
}
685681

686-
private _throwNoPayloadError(op: ObjectOperation<ObjectData>): void {
682+
private _throwNoPayloadError(op: ObjectOperation<ObjectData>): never {
687683
throw new this._client.ErrorInfo(
688684
`No payload found for ${op.action} op for LiveMap objectId=${this.getObjectId()}`,
689685
92000,

0 commit comments

Comments
 (0)