Back to Type Challenges

README

questions/02793-medium-mutable/README.md

latest1.6 KB
Original Source
<!--info-header-start--><h1>Mutable </h1><blockquote><p>by jiangshan <a href="https://github.com/jiangshanmeta" target="_blank">@jiangshanmeta</a></p></blockquote><p><a href="https://tsch.js.org/2793/play" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.zh-CN.md" target="_blank"></a> </p><!--info-header-end-->

Implement the generic Mutable<T> which makes all properties in T mutable (not readonly).

For example

typescript
interface Todo {
  readonly title: string
  readonly description: string
  readonly completed: boolean
}

type MutableTodo = Mutable<Todo> // { title: string; description: string; completed: boolean; }

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

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