title: How to create a TypeScript object with only selected properties?
body: <p>I have a TypeScript object that looks like this:</p>
  <pre><code>class User {
    id: string = &quot;&quot;;
    location: string = &quot;&quot;;
    displayName: string = &quot;&quot;;
    otherAttribute: string = &quot;&quot;;
  }
  </code></pre>
  <p>How can I create an object of type User, with only the fields I want it to have?</p>
  <p>For example, I want to be able to create a User object that only contains <strong>id</strong> and <strong>displayName</strong>, but without the <strong>location</strong> and <strong>otherAttribute</strong> properties. I need to create a new object without unwanted properties to use DynamoDB DataMapper, which is an ORM library that interfaces with DynamoDB and uses the class properties to map to the DynamoDB table attributes dynamically. This was working fine before using plain JavaScript because I didn't declare any property in my JavaScript User class but now need to for TypeScript. Is there a way to get around this?</p>