Back to Type Challenges

README

questions/00057-hard-get-required/README.md

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

Implement the advanced util type GetRequired<T>, which remains all the required fields

For example

ts
type I = GetRequired<{ foo: number, bar?: string }> // expected to be { foo: number }
<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/57/answer" target="_blank"></a> <a href="https://tsch.js.org/57/solutions" target="_blank"></a> <hr><h3>Related Challenges</h3><a href="https://github.com/type-challenges/type-challenges/blob/main/questions/00059-hard-get-optional/README.md" target="_blank"></a> <!--info-footer-end-->