상향된 유틸타입 UnionToIntersection<U>을 구현하라
Implement the advanced util type UnionToIntersection<U>
type UnionToIntersection<U> =
(U extends any ? (arg: U) => any : never) extends ((arg: infer I) => void) ? I : never
지금껏 extends로 분배법칙을 작성하면 유니온 타입으로 작성된다고 생각했다.
그러나, 공변성이 있는 인자의 경우, extends로 분배법칙을 작성하면 유니온 타입이 아닌 intersection(&)으로 합쳐진다.
strictFunctionTypes이 켜져있는 경우에는 인자는 공변성을, 꺼져있는 경우에 인자는 이변성(공변성+반공변성)을 띈다
이변성을 띄는 경우에도 intersection이 구현된다
https://github.com/type-challenges/type-challenges/issues/122