title: How to associate two props parameters types together in Typescript
body: <p>I am creating a component that will be used in two different components. In the component A the main param will be typed as typeA and the callback will have a typeA param and in the other component B the main param will be typed as typeB and the callback will have a typeB param. I am getting an error in the new component1 because the callback can't get variable of typeA | typeB (which makes sense).</p>
  <p>Here is a simple version of how it looks:</p>
  <pre class="lang-js prettyprint-override"><code>type Props = {
    option: typeA | typeB;
    callback: (e, a: typeA) =&gt; void | (e, b: typeB) =&gt; void:
  }
  export const Component1 : (props: Props) =&gt; {
    return (
      &lt;Button onClick={() =&gt; {props.callback(props.option)}&gt; 
        {props.option.label} 
      &lt;/Button&gt;
  
  }
  
  </code></pre>
  <p>Is there a way to associate types together in the props in order to say that the callback from component B will only be associated to a param of typeB?</p>