Flip Arguments
提出詳細
type Reverse<T extends readonly unknown[]> = T extends [infer T1, ...infer T2] ? [...Reverse<[...T2]>, T1] : [] type FlipArguments<T extends Function> = T extends (...args: infer Arg) => infer Ret ? (...args: Reverse<Arg>) => Ret : never
提出日時 | 2023-09-15 14:16:46 |
---|---|
問題 | Flip Arguments |
ユーザー | sankantsu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<FlipArguments<() => boolean>, () => boolean>>, Expect<Equal<FlipArguments<(foo: string) => number>, (foo: string) => number>>, Expect<Equal<FlipArguments<(arg0: string, arg1: number, arg2: boolean) => void>, (arg0: boolean, arg1: number, arg2: string) => void>>, ]