#533Easy

Concat

Implement array concatenation at the type level with TypeScript. Learn about tuple types and the spread operator in this easy-level challenge on TypeScriptPro.

Join arrays together at the type level with Concat! 🔗

In this easy-level challenge, you'll implement the JavaScript Array.concat function in TypeScript's type system. This type takes two tuple arguments and outputs a new tuple that includes all elements from both inputs in left-to-right order.

You'll learn about TypeScript's spread operator in tuple types, a powerful feature for manipulating arrays at the type level. This challenge is perfect for understanding how to work with variadic tuple types.

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

Challenge Instructions: Concat

Easy

Implement the JavaScript Array.concat function in the type system. A type takes the two arguments. The output should be a new array that includes inputs in ltr order

For example:

type Result = Concat<[1], [2]> // expected to be [1, 2]
Loading...

Video Walkthrough

Detailed Explanation

The Concat type uses TypeScript's spread operator to merge tuples at the type level.

type Concat<T extends readonly unknown[], U extends readonly unknown[]> = [
  ...T,
  ...U,
]

How it works:

This mirrors JavaScript's array spread syntax but operates entirely at the type level, demonstrating the elegance of TypeScript's type system in modeling runtime behaviors.

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.