trick typescript into accepting our types.

This commit is contained in:
fiatjaf
2023-09-10 15:44:16 -03:00
parent 55f032d0a4
commit 13bc2ad5a8
2 changed files with 43 additions and 48 deletions

View File

@@ -1,4 +1,4 @@
import { relayInit, type Relay, type Sub, type SubscriptionOptions } from './relay.ts'
import { relayInit, eventsGenerator, type Relay, type Sub, type SubscriptionOptions } from './relay.ts'
import { normalizeURL } from './utils.ts'
import type { Event } from './event.ts'
@@ -118,10 +118,10 @@ export class SimplePool {
}
})
let greaterSub: Sub = {
let greaterSub: Sub<K> = {
sub(filters, opts) {
subs.forEach(sub => sub.sub(filters, opts))
return greaterSub
return greaterSub as any
},
unsub() {
subs.forEach(sub => sub.unsub())
@@ -138,6 +138,9 @@ export class SimplePool {
eventListeners.delete(cb)
} else if (type === 'eose') eoseListeners.delete(cb as () => void | Promise<void>)
},
get events() {
return eventsGenerator(greaterSub)
},
}
return greaterSub