ts-type-forge
    Preparing search index...

    Type Alias Length<T>

    Length: T["length"]

    Extracts the length property type from a type T that has a numeric length property. Typically used for arrays and tuples.

    Type Parameters

    • T extends Readonly<{ length: number }>

      A type with a length: number property (e.g., readonly unknown[]).

    The type of the length property (e.g., number for arrays, a number literal for tuples).

    type TupleLen = Length<[1, 2, 3]>; // 3
    type ArrayLen = Length<string[]>; // number
    type StringLen = Length<"abc">; // 3