Back to Type Challenges

README.Zh CN

questions/02793-medium-mutable/README.zh-CN.md

latest1.7 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/zh-CN" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> </p><!--info-header-end-->

实现一个通用的类型 Mutable<T>,使类型 T 的全部属性可变(非只读)。

例如:

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.zh-CN.md" target="_blank"></a> <a href="https://tsch.js.org/2793/answer/zh-CN" target="_blank"></a> <a href="https://tsch.js.org/2793/solutions" target="_blank"></a> <!--info-footer-end-->