Skip to content

Commit 94e1ce8

Browse files
authored
Safely type stream messages, which are actually items in a collection (#1100)
1 parent 96a851e commit 94e1ce8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/horizon/call_builder.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ export class CallBuilder<
102102
* @param {number} [options.reconnectTimeout] Custom stream connection timeout in ms, default is 15 seconds.
103103
* @returns {Function} Close function. Run to close the connection and stop listening for new events.
104104
*/
105-
public stream(options: EventSourceOptions<T> = {}): () => void {
105+
public stream(options: EventSourceOptions<
106+
T extends ServerApi.CollectionPage<infer U> ? U : T
107+
> = {}): () => void {
106108
// Check if EventSource use is enabled
107109
if (EventSource === undefined){
108110
throw new Error("Streaming requires eventsource to be enabled. If you need this functionality, compile with USE_EVENTSOURCE=true.");

0 commit comments

Comments
 (0)