Skip to content

Commit

Permalink
Safely type stream messages, which are actually items in a collection (
Browse files Browse the repository at this point in the history
  • Loading branch information
challet authored Nov 13, 2024
1 parent 96a851e commit 94e1ce8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/horizon/call_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ export class CallBuilder<
* @param {number} [options.reconnectTimeout] Custom stream connection timeout in ms, default is 15 seconds.
* @returns {Function} Close function. Run to close the connection and stop listening for new events.
*/
public stream(options: EventSourceOptions<T> = {}): () => void {
public stream(options: EventSourceOptions<
T extends ServerApi.CollectionPage<infer U> ? U : T
> = {}): () => void {
// Check if EventSource use is enabled
if (EventSource === undefined){
throw new Error("Streaming requires eventsource to be enabled. If you need this functionality, compile with USE_EVENTSOURCE=true.");
Expand Down

0 comments on commit 94e1ce8

Please sign in to comment.