title: How to Type a deep object destructuring in Typescript?
body: <p>I'm trying to Type a deep object destructuring in Typescript and I have searched a whole bunch but found nothing that quite answers my question, so I thought I'd ask it.</p>
  
  <p>I have something <em>like</em> this in my class:</p>
  
  <pre><code>public Example(
    key1: string,
    key2: string,
    val: string,
    callback: (list: string[]) =&gt; void
  ): void
  {
    chrome.storage.sync.get(
      ({
        [key1]: list1,
        [key2]: list2
      }) =&gt; {
        list1.includes(val)
          ? callback(list1.filter(i =&gt; i !== val))
          : callback(list2)
      }
    );
  }
  </code></pre>
  
  <p>I haven't found a way to Type <code>list1</code> and <code>list2</code> (as <code>string[]</code>) and they get set as <code>any</code> which is no use to me when trying to use array functions. I've found examples of how to Type if the <em>key</em> is known (<code>{ key }: { key: string[] }</code>) but not for my situation. I also can't create a Type as the LHS is non-static.</p>
  
  <p>My example is altered somewhat but contains everything needed to get my question across.</p>
  
  <p>In case it's needed, the <code>chrome.d.ts</code> I have states:</p>
  
  <pre><code>/**
   * Gets one or more items from storage.
   * @param callback Callback with storage items, or on failure (in which case runtime.lastError will be set).
   * Parameter items: Object with items in their key-value mappings.
   */
  get(callback: (items: { [key: string]: any }) =&gt; void): void;
  </code></pre>
  
  <p>I'm sure it's probably really simple and I've just not found anything; that being said, this question might make it easier for other people to find in future so it'd be win-win if solved.</p>
  
  <p>I appreciate all and any help.</p>
  
  <hr>
  
  <p>EDIT: I guess I'm also looking for the case where it's not <em>just</em> <code>string[]</code> that is returned. What if you have a whole bunch of data that were all different types?</p>