title: How to handle objects that can be null in Typescript?
body: <p>I want a function to return either an object or null.</p>
  
  <p>Here is how I handle it today:</p>
  
  <pre><code>export interface MyObject {
      id: string
  }
  
  function test(id) : MyObject | null {
      if (!id) {
          return null;
      }
  
      return {
          id: id
      }
  }
  </code></pre>
  
  <p>Is this best practice?</p>
  
  <p>I would prefer to make the interface nullable rather than returning <code>MyObject | null</code>.</p>
  
  <p>But I don't know if that is possible.</p>