API reference@evolu/commonType › tuple

function tuple<Elements>(
  ...elements: Elements & TupleValidation<Elements>
): TupleType<Elements>;

Defined in: packages/common/src/Type.ts:8841

Tuple Type.

Use tuple(First, Second, ...) for a fixed-length readonly array in which every position has its own Type.

fromUnknown validates the Tuple representation and runs every element's complete Type pipeline. By default, it returns the first issue. Pass { errors: "all" } to collect issues across the whole Tuple.

from accepts the Tuple Output. When any element Type has a parent, from.parent accepts a Tuple of root element Outputs and runs all remaining element stages. This collapsed input boundary keeps a Tuple to at most one .parent suffix even when its element Types have different pipeline depths.

A Tuple must be recognized by Array.isArray, have exactly the declared length, be dense, and have no own properties other than length and the indexed data properties for its elements. Foreign-realm arrays are accepted when their own data representation is valid. Sparse arrays, accessor elements, and excess properties are rejected.

Example

import { assertOk, Int64FromInt64String, String, tuple } from "@evolu/common";

const Entry = tuple(String, Int64FromInt64String);

assertOk(Entry.fromUnknown(["count", "1"]), ["count", 1n]);
assertOk(Entry.from.parent(["count", "1"]), ["count", 1n]);