type-challenges
type-challenges copied to clipboard
296 - Permutation
// 你的答案
type IsNever<T> = [T] extends [never] ? ([never] extends [T] ? true : false) : false
type Permutation<T extends boolean | string> =
{ [P in `${T}`]: [P extends `${infer Bool extends boolean}` ? Bool : P, ...Permutation<Exclude<`${T}`, P>> ] } [`${T}`] extends infer R extends any[] ?
IsNever<T> extends true ? [] : R
:never;