Back to Type Challenges

README

questions/02595-medium-pickbytype/README.md

latest1.5 KB
Original Source
<!--info-header-start--><h1>PickByType </h1><blockquote><p>by jiangshan <a href="https://github.com/jiangshanmeta" target="_blank">@jiangshanmeta</a></p></blockquote><p><a href="https://tsch.js.org/2595/play" target="_blank"></a> </p><!--info-header-end-->

From T, pick a set of properties whose type are assignable to U.

For Example

typescript
type OnlyBoolean = PickByType<{
  name: string
  count: number
  isReadonly: boolean
  isEnable: boolean
}, boolean> // { isReadonly: boolean; isEnable: boolean; }
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/2595/answer" target="_blank"></a> <a href="https://tsch.js.org/2595/solutions" target="_blank"></a> <hr><h3>Related Challenges</h3><a href="https://github.com/type-challenges/type-challenges/blob/main/questions/02852-medium-omitbytype/README.md" target="_blank"></a> <!--info-footer-end-->