Type Challenges Judge

Combination

提出詳細

type CombinationImpl<T extends string, TT extends string=T> = T extends T ? [TT] extends [T] ? T : T | `${T} ${CombinationImpl<Exclude<TT,T>>}` : never type Combination<T extends string[]> = CombinationImpl<T[number]>
提出日時2023-09-18 13:30:22
問題Combination
ユーザーsankantsu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Combination<['foo', 'bar', 'baz']>, 'foo' | 'bar' | 'baz' | 'foo bar' | 'foo bar baz' | 'foo baz' | 'foo baz bar' | 'bar foo' | 'bar foo baz' | 'bar baz' | 'bar baz foo' | 'baz foo' | 'baz foo bar' | 'baz bar' | 'baz bar foo'>>, ]