Skip to content

Commit ce61576

Browse files
committed
fix: tweak internal types
1 parent 19d8580 commit ce61576

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/redis.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ function xreadgroup(
102102
if (noack) args.push('NOACK')
103103
if (isNumber(block)) args.push('BLOCK', block.toString())
104104
debug(`xreadgroup ${args.join(' ')}`)
105+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
106+
// https://github.com/luin/ioredis/pull/1676#issue-1437398115
105107
;(client as any)[buffers ? 'xreadgroupBuffer' : 'xreadgroup'](
106108
...args,
107109
'STREAMS',

src/stream.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import {
88
Mode,
99
modes,
1010
env,
11+
StreamEntry,
1112
} from './types.js'
1213

1314
export { RedisStreamOptions, Mode }
1415

16+
type ResolvedForCaller = any
17+
1518
export class RedisStream<T extends Mode = 'entry'> {
1619
//static factoryFor() { //create factory that extends options }
1720
/**
@@ -50,9 +53,9 @@ export class RedisStream<T extends Mode = 'entry'> {
5053

5154
private itr = {
5255
name: '',
53-
prev: undefined as any,
54-
entry: undefined as any,
55-
stream: undefined as any,
56+
prev: undefined as StreamEntry | undefined,
57+
entry: null as IterableIterator<StreamEntry> | null,
58+
stream: null as IterableIterator<XStreamResult> | null | undefined,
5659
}
5760

5861
/**
@@ -147,14 +150,17 @@ export class RedisStream<T extends Mode = 'entry'> {
147150
else {
148151
this.streams.set(itr.name, this.group ? '>' : result.value[0].toString())
149152
if (this.ackOnIterate) itr.prev = result.value
150-
yield [itr.name, result.value] as any
153+
const ret: XEntryResult = [itr.name, result.value]
154+
yield ret as ResolvedForCaller
151155
}
152156
}
153157
}
154158

155159
private moveCursors() {
156160
if (this.first) {
157-
this.streams.forEach((v, k) => this.streams.set(k, '>'))
161+
for (const [stream] of this.streams) {
162+
this.streams.set(stream, '>')
163+
}
158164
this.first = false
159165
}
160166
}
@@ -176,13 +182,14 @@ export class RedisStream<T extends Mode = 'entry'> {
176182
}
177183
}
178184

179-
public ack(stream: string, ...ids: string[]): void {
185+
public ack(stream: string, ...ids: string[]): undefined {
180186
if (!this.group) {
181187
throw new Error('Cannot ack entries read outside of a consumer group')
182188
}
183189
const acks = this.pendingAcks.get(stream) || []
184190
acks.push(...ids)
185191
this.pendingAcks.set(stream, acks)
192+
return
186193
}
187194

188195
protected async return(): Promise<void> {

0 commit comments

Comments
 (0)