Type alias Repeat<Char, Count, Joined, Acc>

Repeat<Char, Count, Joined, Acc>: Acc["length"] extends Count
    ? Joined
    : Repeat<Char, Count, `${Joined}${Char}`, [0, ...Acc]>

Repeat string

Type Parameters

  • Char extends string
  • Count extends number
  • Joined extends string = ""
  • Acc extends 0[] = []

Example

const x: Repeat<'1' | '2', 4> = '1122'

Source