Back to Type Challenges

README

questions/05181-hard-mutable-keys/README.md

latest1.5 KB
Original Source
<!--info-header-start--><h1>Mutable Keys </h1><blockquote><p>by Yugang Cao <a href="https://github.com/Talljack" target="_blank">@Talljack</a></p></blockquote><p><a href="https://tsch.js.org/5181/play" target="_blank"></a> </p><!--info-header-end-->

Implement the advanced util type MutableKeys<T>, which picks all the mutable (not readonly) keys into a union.

For example:

ts
type Keys = MutableKeys<{ readonly foo: string; bar: number }>;
// expected to be “bar”
<!--info-footer-start-->

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