39. 对象的差值类型
中等
实现一个通用工具类型 Diff<O, O1>
,将两个对象类型中的差值属性提取并返回一个新的对象类型。
例如:
type Foo = {
a: string;
b: number;
}
type Bar = {
a: string;
c: boolean
}
type Result1 = Diff<Foo, Bar> // expected to be { b: number, c: boolean }
type Result2 = Diff<Bar, Foo> // expected to be { b: number, c: boolean }