Flip Arguments
提出詳細
type Reverse<T extends readonly unknown[], Acc extends readonly unknown[] = []> = T extends [infer Head, ...infer Rest] ? Reverse<Rest, [Head, ...Acc]> : Acc type FlipArguments<T extends Function> = T extends (...args: infer U) => infer K ? (...args: Reverse<U>) => K: never
提出日時 | 2025-09-16 06:16:52 |
---|---|
問題 | Flip Arguments |
ユーザー | balckowl |
ステータス | 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>>, ]