Back to Type Challenges

README.Zh CN

questions/00043-easy-exclude/README.zh-CN.md

latest1.8 KB
Original Source
<!--info-header-start--><h1>实现 Exclude </h1><blockquote><p>by Zheeeng <a href="https://github.com/zheeeng" target="_blank">@zheeeng</a></p></blockquote><p><a href="https://tsch.js.org/43/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-->

实现内置的 Exclude<T, U> 类型,但不能直接使用它本身。

从联合类型 T 中排除 U 中的类型,来构造一个新的类型。

例如:

ts
type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c'
<!--info-footer-start-->

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