Creates a TupleTypeGuard that validates that the array has the exact length and types match at each position.
TupleTypeGuard
Best practice: pass the generic type argument into isTuple to avoid unexpected optional-field behavior.
isTuple
The tuple type to guard
An array of type guards corresponding to each position in the tuple
A type guard for T
T
type Row = [number, string?];const isRow = isTuple<Row>([isNumber, isString.optional()]);isRow([6, "Hello"]); // trueisRow([6]); // trueisRow(["Hello", "Bye"]); // false Copy
type Row = [number, string?];const isRow = isTuple<Row>([isNumber, isString.optional()]);isRow([6, "Hello"]); // trueisRow([6]); // trueisRow(["Hello", "Bye"]); // false
Creates a
TupleTypeGuardthat validates that the array has the exact length and types match at each position.Best practice: pass the generic type argument into
isTupleto avoid unexpected optional-field behavior.