title: typescript null safe destructure
body: <p>I have typed graphql queries that can be deep objects where every level can be nullable which makes my destructuring code look pretty bad...</p>
  
  <pre><code>const { levelOne } = data || {} as keyof typeof data;
  conse { levelTwo } = levelOne || {} as keyof typeof levelOne;
  ...
  </code></pre>
  
  <p>can I make this cleaner by providing a null safe destructure function...</p>
  
  <pre><code>const safeDestructure = &lt;T extends {}&gt;(obj:T): T =&gt; {
    return obj || {} as keyof typeof obj;
  }
  </code></pre>
  
  <p>or is there a better way to do either the inline destructuring or the safe destructure function?</p>