Type Challenges Judge

Permutation

提出詳細

type Helper<T,U> = T extends unknown ? (Exclude<U,T> extends never ? [T] : [T,...Permutation<Exclude<U,T>>]) : never type Permutation<T> = { [key in T & PropertyKey]: Helper<key,T> }[T & PropertyKey]
提出日時2023-09-13 16:18:31
問題Permutation
ユーザーsankantsu
ステータスWrong Answer
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Permutation<'A'>, ['A']>>, Expect<Equal<Permutation<'A' | 'B' | 'C'>, ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', 'C'] | ['B', 'C', 'A'] | ['C', 'A', 'B'] | ['C', 'B', 'A']>>, Expect<Equal<Permutation<'B' | 'A' | 'C'>, ['A', 'B', 'C'] | ['A', 'C', 'B'] | ['B', 'A', 'C'] | ['B', 'C', 'A'] | ['C', 'A', 'B'] | ['C', 'B', 'A']>>, Expect<Equal<Permutation<never>, []>>, ]