O & O1의 차이점인 객체를 가져옵니다
type Diff<O extends object, O1 extends object> = {
[R in Exclude<keyof O,keyof O1>|Exclude<keyof O1,keyof O>]:R extends keyof O? O[R]:R extends keyof O1?O1[R]:never;
}
두 객체 키의 차집합을 구해서 그걸 mapped 타입에서 사용함
type Diff<O, O1> = Omit<O & O1, keyof (O | O1)>
이 풀이에서는 이렇게 제시를 한다
https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#working-with-union-types
다른 사람의 풀이에서 제시한 대로, union type을 사용하고, 유니온 타입 중 하나의 키에 접근하려고 하면, 공통된 키에만 접근할 수 있다. 그 점을 이용하면 문제를 쉽게 풀 수 있다.
https://github.com/type-challenges/type-challenges/issues/3014
https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#working-with-union-types