Back to Type Challenges

README

questions/29650-medium-extracttoobject/README.md

latest1.4 KB
Original Source
<!--info-header-start--><h1>ExtractToObject </h1><blockquote><p>by Maxim Bazuev <a href="https://github.com/bazuka5801" target="_blank">@bazuka5801</a></p></blockquote><p><a href="https://tsch.js.org/29650/play" target="_blank"></a> </p><!--info-header-end-->

Implement a type that extract prop value to the interface. The type takes the two arguments. The output should be an object with the prop values. Prop value is object.

For example

ts
type Test = { id: '1', myProp: { foo: '2' }}
type Result = ExtractToObject<Test, 'myProp'> // expected to be { id: '1', foo: '2' }
<!--info-footer-start-->

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