nested array typescript type

    type FixedArray<T, D extends number> = Array<T> & {
        length: D
    }

    type NestedArrays<T> = Array<T | NestedArrays<T>>

type FixedArray<T, D extends number> = Array<T> & {
    length: D
}

const a: FixedArray<FixedArray<FixedArray<number, 2>, 2>, 3> = [
    [
        [1, 2],
        [1, 2],
    ],
    [
        [1, 2],
        [1, 2],
    ],
    [
        [1, 2],
        [1, 2],
    ],
]

I’ve never been able to get the array length to be automatically inferred from the child elements