DEV Community

Discussion on: Advanced TypeScript Exercises - Question 4

Collapse
 
kashyaprahul94 profile image
Rahul Kashyap
// lets say we have some function type
type SomeF = (a: number, b: string) => number

// and we have our utility type
type AppendArgument<F extends (...args: any[]) => any, A> = (x: A, ...args: Parameters<F>) => ReturnType<F>

type FinalF = AppendArgument<SomeF, boolean> 
// FinalF should be (x: boolean, a: number, b: string) => number
Enter fullscreen mode Exit fullscreen mode

Playground Link

Collapse
 
muzichen profile image
ChenLee

You should keep the arguments' order, so x must after a and b.