Flip Arguments
提出詳細
type ReverseTpl<T extends unknown[]> = T extends [infer E, ...infer R] ? [...ReverseTpl<R>, E] : [] type FlipArguments<T extends (...args: never[]) => unknown> = (...args: ReverseTpl<Parameters<T>>) => ReturnType<T>
提出日時 | 2023-09-02 16:15:29 |
---|---|
問題 | Flip Arguments |
ユーザー | ookkoouu |
ステータス | 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>>, ]