Skip to main content

Type Alias: StreamObjectElement<T, K>

StreamObjectElement<T, K> = string extends K ? unknown : K extends keyof T ? NonNullable<T[K]> extends ReadonlyArray<infer E> ? E : never : never

Defined in: packages/agentos/src/api/streamObject.ts:52

The type of one element of the array field K of T, which StreamObjectResult.elementStream yields when StreamObjectOptions.elements names K: never when K names no field of T that holds an array (and when no field was named), and unknown when K is a string whose value the type does not know.

Type Parameters​

T​

T

The object type the schema infers.

K​

K extends string

The field name given as elements.

Example​

type Sentence = StreamObjectElement<{ sentences: { text: string }[] }, 'sentences'>;
// { text: string }