[...TupleOf<N, T>, ...T[]]Constructs a tuple type with at least N elements of type T.
When to use
Use when you need a minimum-length array type that still allows additional elements. This is useful for variadic function signatures that require a minimum arity.
Details
Produces a tuple with N fixed positions followed by ...Array<T>.
Example (Checking minimum-length tuples)
import type { Types } from "effect"
// At least 2 strings
const ok1: Types.TupleOfAtLeast<2, string> = ["a", "b"]
const ok2: Types.TupleOfAtLeast<2, string> = ["a", "b", "c", "d"]
// @ts-expect-error - too few elements
const bad: Types.TupleOfAtLeast<2, string> = ["a"]export type type TupleOfAtLeast<
N extends number,
T
> = [...TupleOf<N, T>, ...T[]]
Constructs a tuple type with at least N elements of type T.
When to use
Use when you need a minimum-length array type that still allows additional
elements. This is useful for variadic function signatures that require a
minimum arity.
Details
Produces a tuple with N fixed positions followed by ...Array<T>.
Example (Checking minimum-length tuples)
import type { Types } from "effect"
// At least 2 strings
const ok1: Types.TupleOfAtLeast<2, string> = ["a", "b"]
const ok2: Types.TupleOfAtLeast<2, string> = ["a", "b", "c", "d"]
//
TupleOfAtLeast<function (type parameter) N in type TupleOfAtLeast<N extends number, T>N extends number, function (type parameter) T in type TupleOfAtLeast<N extends number, T>T> = [...type TupleOf<
N extends number,
T
> = N extends N
? number extends N
? T[]
: TupleOf_<T, N, []>
: never
Constructs a tuple type with exactly N elements of type T.
When to use
Use when you need a fixed-length array type, especially instead of manually
writing [T, T, T, ...] for longer tuples.
Details
- If
N is a literal number, produces a tuple of that exact length.
- If
N is the general number type (non-literal), degrades to Array<T>.
- Negative numbers produce
never.
Example (Checking fixed-length tuples)
import type { Types } from "effect"
// Exactly 3 numbers
const triple: Types.TupleOf<3, number> = [1, 2, 3]
//
TupleOf<function (type parameter) N in type TupleOfAtLeast<N extends number, T>N, function (type parameter) T in type TupleOfAtLeast<N extends number, T>T>, ...interface Array<T>Array<function (type parameter) T in type TupleOfAtLeast<N extends number, T>T>]