01. Concat
Last updated
Last updated
type Result = Concat<[1], [2]> // expected to be [1, 2]type Concat<T, U> = ...
// 1. spread 문법을 이용해서 두 배열타입을 나열해준다. 이렇게하면 에러 발생
type Concat<T, U> = [...T, ...U]
// 2. 제한을 걸어서 에러를 해결하자. 제한은 이전에 conditional types 를 하면서 학습했다.
type Concat<T extends unknown[], U extends unknown[]> = [...T, ...U];