import { TupleKeys } from "./TupleKeys.js"; /** * Increment lookup table for counting fixed tuple elements. * Supports tuples with up to 8 fixed elements. */ type Increment = [1, 2, 3, 4, 5, 6, 7, 8]; type LargerDigits = D extends 0 | Increment[number] ? [ 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9, 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9, 3 | 4 | 5 | 6 | 7 | 8 | 9, 4 | 5 | 6 | 7 | 8 | 9, 5 | 6 | 7 | 8 | 9, 6 | 7 | 8 | 9, 7 | 8 | 9, 8 | 9, 9 ][D] : never; /** * Count the number of fixed elements in a tuple by checking sequential indices. * Returns the count of fixed elements (0 for plain arrays, N for [T1, T2, ...TN, ...rest[]]). */ type CountFixed = `${N}` extends TupleKeys ? N extends keyof Increment ? CountFixed : N : N; type NonZeroDigit = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"; /** * Get the appropriate array index type for autocomplete. * - Plain arrays (string[]): ArrayIndex (suggests "0") * - Rest tuples ([string, ...number[]]): suggests fixed keys + first rest index */ export type ArrayIndex = number extends T["length"] ? TupleKeys | `${CountFixed}` | `${string}${LargerDigits>}` | `${NonZeroDigit}${number}` : TupleKeys; export {}; //# sourceMappingURL=ArrayIndex.d.ts.map