Type alias TLengthOfString<S, Acc>

TLengthOfString<S, Acc>: S extends `${string}${infer $Rest}`
    ? TLengthOfString<$Rest, [...Acc, 0]>
    : Acc["length"]

Type that returns the length of a string.

Type Parameters

  • S extends string

  • Acc extends 0[] = []

Remarks

tail-end recursive approach: returns the type itself to reuse stack of previous call

Generated using TypeDoc