import Runtype, { type Parsed, type Static } from "./Runtype.js"; import Spread from "./Spread.js"; import type HasSymbolIterator from "./utils-internal/HasSymbolIterator.js"; /** * Validates that a value fulfills one of the given runtypes. * * Possible failures: * * - `TYPE_INCORRECT` with `details` reporting failures for each runtype */ interface Union extends Runtype<{ [K in keyof R]: R[K] extends Runtype.Core ? Static : unknown; }[number], { [K in keyof R]: R[K] extends Runtype.Core ? Parsed : unknown; }[number]> { tag: "union"; alternatives: R; [Symbol.iterator]: R["length"] extends 1 ? R[0] extends Runtype.Spreadable ? HasSymbolIterator extends true ? () => Iterator> : never : never : never; match: Match; } type Match = >(...cases: C) => Matcher>; type Matcher = (value: { [K in keyof R]: Static; }[number]) => Z; type Cases = { [K in keyof R]: Case; }; type Case = (value: Parsed) => Y; declare const Union: (...alternatives: R) => Union; export default Union;