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

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

    The object type the schema infers.

  • K extends string

    The field name given as elements.

Example

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