Back to Type Challenges

README.Ja

questions/00005-extreme-readonly-keys/README.ja.md

latest2.0 KB
Original Source
<!--info-header-start--><h1>Get Readonly Keys </h1><blockquote><p>by Anthony Fu <a href="https://github.com/antfu" target="_blank">@antfu</a></p></blockquote><p><a href="https://tsch.js.org/5/play/ja" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.md" target="_blank"></a> <a href="./README.zh-CN.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> <a href="./README.pt-BR.md" target="_blank"></a> </p><!--info-header-end-->

オブジェクトの読み取り専用キーの Union を返す汎用的な GetReadonlyKeys<T> を実装してください。

例えば

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

type Keys = GetReadonlyKeys<Todo> // expected to be "title" | "description"
<!--info-footer-start-->

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