Skip to main content

$union

Callable

  • $union<Elements>(union: Elements, options?: SchemaOptions<object, NoInfer<ToInfer<_TupleElements<{ [ K in string | number | symbol ]: Elements[K<K>] extends (...args: any[]) => R ? R : Elements[K<K>] }>>[number]>>): UnionType<TupleElements<Elements>>

  • Create a new UnionType instance with the given options.

    Example

    $union([$integer, $string])

    $union([$object({foo: $integer}), $object({bar: $string}])

    Type parameters

    • Elements: ConstExpr<Node>[]

    Parameters

    • union: Elements

      The items in the union.

    • options: SchemaOptions<object, NoInfer<ToInfer<_TupleElements<{ [ K in string | number | symbol ]: Elements[K<K>] extends (...args: any[]) => R ? R : Elements[K<K>] }>>[number]>> = {}

      Additional options to pass to the tuple.

    Returns UnionType<TupleElements<Elements>>