Type Alias IsTuple<T, $O>

IsTuple<T, $O>: $SpecialType<T, $MergeOptions<$O, {
    $else: IsTuple.$<T, $O>;
    $then: $ResolveBranch<T, $O, [$Else]>;
}>>

🎭 predicate

Validate that T is a tuple, excluding array.

type R = IsTuple<[]>       // true

type R = IsTuple<number[]> // false
type R = IsTuple<string> // false
type R = IsTuple<never> // false
type R = IsTuple<unknown> // false

🔢 customize

Filter to ensure T is a tuple, otherwise returns never.

Type Parameters

type R = IsTuple<[], { selection: 'filter' }> // []
type R = IsTuple<[1], { selection: 'filter' }> // [1]

type R = IsTuple<never, { selection: 'filter' }> // never
type R = IsTuple<unknown, { selection: 'filter' }> // never
type R = IsTuple<[] | boolean, { selection: 'filter' }> // []

🔢 customize:

Disable distribution of union types.

type R = IsTuple<[1] | 1> // boolean
type R = IsTuple<[] | 1, { distributive: false }> // false

🔢 customize

Use unique branch identifiers to allow precise processing of the result.

type R = IsTuple<[], IsTuple.$Branch> // $Then
type R = IsTuple<string, IsTuple.$Branch> // $Else