Currying 1
提出詳細
type Currying<T> = T extends (...args: infer A) => infer Ret ? A extends [infer First, ...infer Rest] ? (arg: First) => Currying<(...args: Rest) => Ret> : Ret : T declare function Currying<T>(fn: T): Currying<T>
提出日時 | 2023-08-13 10:09:43 |
---|---|
問題 | Currying 1 |
ユーザー | tekihei2317 |
ステータス | Accepted |
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 >>, ]