-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00533-easy-concat.ts
44 lines (33 loc) · 1.08 KB
/
00533-easy-concat.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
533 - Concat
-------
by Andrey Krasovsky (@bre30kra69cs) #easy #array
### Question
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]
```
> View on GitHub: https://tsch.js.org/533
*/
/* _____________ Your Code Here _____________ */
type Concat<T extends unknown[], U extends unknown[]> = [...T, ...U]
/* _____________ Test Cases _____________ */
import type { Equal, Expect } from '@type-challenges/utils'
type cases = [
Expect<Equal<Concat<[], []>, []>>,
Expect<Equal<Concat<[], [1]>, [1]>>,
Expect<Equal<Concat<[1, 2], [3, 4]>, [1, 2, 3, 4]>>,
Expect<
Equal<
Concat<['1', 2, '3'], [false, boolean, '4']>,
['1', 2, '3', false, boolean, '4']
>
>
]
/* _____________ Further Steps _____________ */
/*
> Share your solutions: https://tsch.js.org/533/answer
> View solutions: https://tsch.js.org/533/solutions
> More Challenges: https://tsch.js.org
*/