Back to Type Challenges

README

questions/02946-medium-objectentries/README.md

latest1.3 KB
Original Source
<!--info-header-start--><h1>ObjectEntries </h1><blockquote><p>by jiangshan <a href="https://github.com/jiangshanmeta" target="_blank">@jiangshanmeta</a></p></blockquote><p><a href="https://tsch.js.org/2946/play" target="_blank"></a> </p><!--info-header-end-->

Implement the type version of Object.entries

For example

typescript
interface Model {
  name: string;
  age: number;
  locations: string[] | null;
}
type modelEntries = ObjectEntries<Model> // ['name', string] | ['age', number] | ['locations', string[] | null];
<!--info-footer-start-->

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