#191β€’Medium

Append Argument

For given function type `Fn`, 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 `Fn` as the first argument, `A` as the second, and will produce function type `G` which will be the same as `Fn` but with appended argument `A` as a last one. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

For given function type Fn, 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 Fn as the first argument, A as the second, and will produce function type G which will be the same as Fn but with appended argument A as a last one. 🎯

In this medium-level challenge, you'll for given function type fn, 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 fn as the first argument, a as the second, and will produce function type g which will be the same as fn but with appended argument a as a last one.. Master advanced TypeScript type manipulation in this medium-level challenge on TypeScriptPro.

This challenge will teach you essential skills for advanced TypeScript development and type-level programming.

For this challenge, you will need to change the following code to make the tests pass (no type check errors).

Challenge Instructions: Append Argument

Medium

For given function type Fn, 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 Fn as the first argument, A as the second, and will produce function type G which will be the same as Fn but with appended argument A as a last one.

For example,

type Fn = (a: number, b: string) => number
 
type Result = AppendArgument<Fn, boolean>
// expected be (a: number, b: string, x: boolean) => number

This question is ported from the original article by @maciejsikora

Loading...

Video Walkthrough

Detailed Explanation

This challenge requires understanding of TypeScript's type system.

The solution involves carefully constructing types that satisfy all test cases while handling edge cases properly.

This challenge helps you understand TypeScript's advanced type system and how to apply this concept in real-world scenarios.

Share this challenge

Join early, learn faster.

Be the first to access the course, unlock exclusive launch bonuses, and get special early-bird pricing before anyone else.

No spam, unsubscribe at any time. We respect your privacy.

Limited Availability

Only 27 Spots left

Early Access

Get 1 month early access

>75% Off

Pre-Launch discount

This challenge is originally from here.