Skip to content

Commit d5f9e16

Browse files
committed
fix: Correct this usage in static methods
1 parent 8cb2e4e commit d5f9e16

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/queue.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ export class Queue<
9292
protected stats: QueueStats;
9393

9494
/** Wrap the payload in a JSON encoding */
95-
static encodePayload(p: unknown) {
95+
static encodePayload(this: void, p: unknown) {
9696
return JSON.stringify({ _: p });
9797
}
9898

9999
/** Decode the payload, stripping away the outer JSON encoding */
100-
static decodePayload<T>(s: string | null | unknown) {
100+
static decodePayload<T>(this: void, s: string | null | unknown) {
101101
return JSON.parse((s as string) ?? "{}")._ as T;
102102
}
103103

@@ -117,8 +117,12 @@ export class Queue<
117117
},
118118
statInterval:
119119
options?.statInterval === 0 ? 0 : options?.statInterval ?? 5,
120-
decodePayload: options?.decodePayload ?? this.constructor.decodePayload,
121-
encodePayload: options?.encodePayload ?? this.constructor.encodePayload,
120+
decodePayload:
121+
options?.decodePayload ??
122+
(this.constructor as typeof Queue).decodePayload,
123+
encodePayload:
124+
options?.encodePayload ??
125+
(this.constructor as typeof Queue).encodePayload,
122126
};
123127

124128
// initialize stats

0 commit comments

Comments
 (0)