Skip to main content

Concat

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:

ts
type Result = Concat<[1], [2]> // expected to be [1, 2]
Cannot find name 'Concat'.2304Cannot find name 'Concat'.
ts
type Result = Concat<[1], [2]> // expected to be [1, 2]
Cannot find name 'Concat'.2304Cannot find name 'Concat'.
Solution ✅
ts
type Concat<A extends any[], B extends any[]> = [...A, ...B]
 
type Result = Concat<[1], [2]> // expected to be [1, 2]
ts
type Concat<A extends any[], B extends any[]> = [...A, ...B]
 
type Result = Concat<[1], [2]> // expected to be [1, 2]