title: How to type a function that add a property with generics in typescript?
body: <p>Consider this function:</p>
  <pre class="lang-js prettyprint-override"><code>export function addAge(obj) {
    Object.defineProperty(obj, 'age', {
      value: null,
    });
    return obj;
  }
  </code></pre>
  <p>Could I use generics in typescript for know that I will return the object for the parameter with a new property?</p>
  <p>Using like so:</p>
  <pre class="lang-js prettyprint-override"><code>interface IPerson {
   name: string;
  }
  
  const person: IPerson = { name: 'Juan' };
  
  const result = addAge&lt;IPerson&gt;(person);
  // result.age // number | null
  // result.name // string
  </code></pre>