title: Typescript make one parameter type depend on the other parameter
body: <p>Say I have</p>
  <pre><code>interface Action&lt;T&gt; {
      assignAction(key: keyof T, value: any): void;
  }
  </code></pre>
  <p>Say <code>T</code> is of type</p>
  <pre><code>{
      users: User[];
      accounts: Account[];
  }
  </code></pre>
  <p>Now, when calling <code>assignAction</code>, let's say I want to pass <code>users</code>. So this action is false because types don't match:</p>
  <pre><code>assignAction('users', accounts)
  </code></pre>
  <p>I don't know how to validate <code>value</code>, since its type depends on what you choose for <code>key</code>.</p>