title: Typescript: Strong-typing (and autocomplete) for a value based on a sibling object's keys
body: <p>Say I have an object that looks like this:</p>
  <pre class="lang-js prettyprint-override"><code>const configuration: Config = {
    options: {
      'Option 1': 'some value here',
      'Option 2': 'some other value here'
    },
    defaultOption: 'Option 1'
  }
  </code></pre>
  <p>How can I write the type <code>Config</code> such that:</p>
  <ul>
  <li><code>defaultOption</code> can only be one of the keys in the <code>.options</code> object. ie. <code>'Option 1'</code> or <code>'Option 2'</code> in the case above.</li>
  <li><code>.options</code> can have any number of key-value pairs.</li>
  <li>The user doesn't have to specify the <code>.options</code> keys upfront. So, the user shouldn't have to specify <code>const configuration: Config&lt;'Option 1' | 'Option 2'&gt; = ...</code>. It's ok to use generics, but the user shouldn't have to specify them.</li>
  </ul>