Type alias Strlen<S, Arr>

Strlen<S, Arr>: S extends `${infer L}${infer R}`
    ? Strlen<R, [...Arr, L]>
    : Arr["length"]

Get the length of a given string type S

Type Parameters

  • S extends string
  • Arr extends any[] = EmptyArray

Example

Strlen<'foo'>; // Result: 3