Join
提出詳細
type Join<T extends string[], U extends string | number> = T extends [infer L, infer R, ...infer O] ? L extends string ? R extends string ? O extends string[] ? Join<[`${L}${U}${R}`, ...O], U> : `${L}${U}${R}` : never : never : T extends [infer L, ...infer O] ? L : never
提出日時 | 2023-08-07 16:58:39 |
---|---|
問題 | Join |
ユーザー | ookkoouu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Join<['a', 'p', 'p', 'l', 'e'], '-'>, 'a-p-p-l-e'>>, Expect<Equal<Join<['Hello', 'World'], ' '>, 'Hello World'>>, Expect<Equal<Join<['2', '2', '2'], 1>, '21212'>>, Expect<Equal<Join<['o'], 'u'>, 'o'>>, ]