title: Extract type from nested parameter
body: <p>I want to use the value of a function parameter in the return type.<br><br>
  Consider the following function:</p>
  <pre><code>export function trackKeys(node: HTMLElement, { names }: {
      names: string[];
  }) {
      const methods: { [k in typeof names[number]]: (e: Event) =&gt; void } = names.reduce((obj, name) =&gt; {
          return {
              ...obj,
              [name]: (e: Event) =&gt; {
                  // Do something
              },
          };
      }, {});
  }
  </code></pre>
  <p>Here, the &quot;methods&quot; have the type of <code>{ [k in typeof names[number]]: (e: Event) =&gt; void }</code>, which essentially becomes &quot;string&quot;. I would like to have the object keys extracted from the &quot;names&quot; parameter supplied to the function. So that it will be something like:<br>
  <code>{ [k in &quot;john&quot;|&quot;david&quot;|&quot;henry&quot;]: (e: Event) =&gt; void }</code> if the function is called like <code>trackKeys(node, {names: [&quot;john&quot;, &quot;henry&quot;, &quot;david&quot;]});</code></p>
  <p>An example:</p>
  <pre><code>const obj = trackKeys(node, {names: [&quot;apple&quot;, &quot;potato&quot;]});
  //Expected type {&quot;apple&quot;:(e: Event) =&gt; void, &quot;potato&quot;:(e: Event) =&gt; void};
  </code></pre>