Type Challenges Judge

Append Argument

提出詳細

type AppendArgument<Fn extends (...args: any[]) => unknown, A, R = ReturnType<Fn>> = Fn extends (...args: infer P) => unknown ? (...args: [...P, A]) => R :never;
提出日時2022-06-27 12:55:27
問題Append Argument
ユーザーwaki285
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type Case1 = AppendArgument<(a: number, b: string) => number, boolean> type Result1 = (a: number, b: string, x: boolean) => number type Case2 = AppendArgument<() => void, undefined> type Result2 = (x: undefined) => void type cases = [ Expect<Equal<Case1, Result1>>, Expect<Equal<Case2, Result2>>, ]