Back to Type Challenges

README

questions/00527-medium-append-to-object/README.md

latest1.8 KB
Original Source
<!--info-header-start--><h1>Append to object </h1><blockquote><p>by Andrey Krasovsky <a href="https://github.com/bre30kra69cs" target="_blank">@bre30kra69cs</a></p></blockquote><p><a href="https://tsch.js.org/527/play" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.zh-CN.md" target="_blank"></a> <a href="./README.ja.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> </p><!--info-header-end-->

Implement a type that adds a new field to the interface. The type takes the three arguments. The output should be an object with the new field.

For example

ts
type Test = { id: '1' }
type Result = AppendToObject<Test, 'value', 4> // expected to be { id: '1', value: 4 }
<!--info-footer-start-->

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