genkit icon indicating copy to clipboard operation
genkit copied to clipboard

Fix: Propagate Generic Type to `GenerateStreamResponse.stream`

Open Dinesh-Gautam opened this issue 3 months ago • 1 comments

Fixes: #3603

Context

The GenerateStreamResponse interface did not propagate its generic O type to the stream property.
As a result, the chunks yielded by stream were always typed as GenerateResponseChunk<unknown>,
forcing users to manually assert types and losing schema-based type inference.

What Was Changed

Updated the GenerateStreamResponse interface to propagate the generic O type to the stream property.

After Changes

Screenshot 2025-09-22 211707

Checklist (if applicable):

  • [x] PR title is following https://www.conventionalcommits.org/en/v1.0.0/
  • [x] Tested (manually, unit tested, etc.)
  • [ ] Docs updated (updated docs or a docs bug required)

Dinesh-Gautam avatar Sep 22 '25 16:09 Dinesh-Gautam

I've encountered the same type inference issue with the stream response. It would be great if this could be merged soon as it's blocking proper TypeScript support for streaming.

parkcoool avatar Nov 25 '25 03:11 parkcoool

@apascal07 quick follow-up on this PR when you have a moment. Happy to adjust anything if needed. Thanks!

Dinesh-Gautam avatar Dec 07 '25 07:12 Dinesh-Gautam