Advanced TypeScript Exercises - Question 4

macsikora

Pragmatic Maciej

Posted on February 20, 2020

Advanced TypeScript Exercises - Question 4

For given function type F, and any type A (any in this context means we don't restrict the type, and I don't have in mind any type 😉) create a generic type which will take F as first argument, A as second and will produce function type G which will be the same as F but with appended argument A as a first one.

// lets say we have some function type
type SomeF = (a: number, b: string) => number
// and we have our utility type
type AppendArgument<F, A> = ... here your code 💪

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

Post your answers in comments. Have fun! Answer will be published soon!

This series is just starting. If you want to know about new exciting questions from advanced TypeScript please follow me on dev.to and twitter.

💖 💪 🙅 🚩
macsikora
Pragmatic Maciej

Posted on February 20, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related