Back to Type Challenges

README.Zh CN

questions/00645-medium-diff/README.zh-CN.md

latest1.8 KB
Original Source
<!--info-header-start--><h1>Diff </h1><blockquote><p>by ZYSzys <a href="https://github.com/ZYSzys" target="_blank">@ZYSzys</a></p></blockquote><p><a href="https://tsch.js.org/645/play/zh-CN" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> <a href="./README.ja.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> </p><!--info-header-end-->

获取两个接口类型中的差值属性。

ts
type Foo = {
  a: string;
  b: number;
}
type Bar = {
  a: string;
  c: boolean
}

type Result1 = Diff<Foo,Bar> // { b: number, c: boolean }
type Result2 = Diff<Bar,Foo> // { b: number, c: boolean }

<!--info-footer-start-->

<a href="../../README.zh-CN.md" target="_blank"></a> <a href="https://tsch.js.org/645/answer/zh-CN" target="_blank"></a> <a href="https://tsch.js.org/645/solutions" target="_blank"></a> <!--info-footer-end-->