Currying 1
提出詳細
type Currying<T> = T extends (...arg: infer Arg) => infer Ret ? Arg["length"] extends 0 | 1 ? T : Arg extends [infer L, ...infer R] ? (a: L) => Currying<(...a: R) => Ret> : Ret : never;
提出日時 | 2023-08-30 08:05:34 |
---|---|
問題 | Currying 1 |
ユーザー | ookkoouu |
ステータス | Wrong Answer |
import type { Equal, Expect } from '@type-challenges/utils' const curried1 = Currying((a: string, b: number, c: boolean) => true) const curried2 = Currying((a: string, b: number, c: boolean, d: boolean, e: boolean, f: string, g: boolean) => true) type cases = [ Expect<Equal< typeof curried1, (a: string) => (b: number) => (c: boolean) => true >>, Expect<Equal< typeof curried2, (a: string) => (b: number) => (c: boolean) => (d: boolean) => (e: boolean) => (f: string) => (g: boolean) => true >>, ]