title: Typescript, ES6, Angular 12: map/copy similar object
body: <p>I have two model objects which are very similar (Angular 12 frontend):</p>
  <pre><code>export interface UserGet {
     id: string;
     firstName: string;
     lastName: string;
     hobby: Hobby;
  }
  
  export interface UserPost {
     firstName: string;
     lastName: string;
     hobby: number;
  }
  
  export interface Hobby {
     id: string;
     hobby: string;
  }
  </code></pre>
  <p>I want to map the a UserGet-object to a UserPost-object.</p>
  <p>Current approach with a given userGet-object:</p>
  <pre><code>const userPost: userPost = {
     firstName: this.userGet.firstName,
     lastName: this.userGet.lastName,
     hobby: this.userGet.hobby.id;
   }
  </code></pre>
  <p>Looks simple, however in reality, I have a lot of more fields and I need to map alot of more objects in the same approach.</p>
  <p>Is there a shorter/more elegant ES6 typescript solution to map models which, similar to my example, have the following structure:</p>
  <ul>
  <li>some fields might be missing in the target object</li>
  <li>some fields might be of different type in the target object</li>
  </ul>
  <p>Thanks in advance</p>