title: How to get the right type from type object with generic in typescript
body: <p>I have an enum</p>
  <pre><code>export const trackingKeys = {
    Form: 'form',
    Video: 'video',
  } as const
  
  </code></pre>
  <p>I have a type who give for a key a type property</p>
  <pre><code>export type TrackingPropertiesByKey = {
    [trackingKeys.Form]: { bar : number }
    [trackingKeys.Video]: { foo : boolean }
  }
  </code></pre>
  <p>And a track function</p>
  <pre><code>export type TrackingEventKey =
    typeof trackingKeys[keyof typeof trackingKeys]
  
  const track = &lt;T extends TrackingEventKey&gt;(
      event: TrackingEventKey,
      properties?: TrackingPropertiesByKey[T]
    ) =&gt; trackFromLib(event, properties)
  </code></pre>
  <p>Using <code>track(trackingKeys.Form, {foo : true, bar: 1 })</code> doesn't give me na error.</p>
  <p>I've got the following type :</p>
  <pre><code>const track: &lt;TrackingEventKey&gt;(event: TrackingEventKey, properties?: {
      bar: number;
  } | {
      foo: boolean;
  }) =&gt; void
  </code></pre>
  <p>I don't want to have <code>properties?: {bar: number;}|{foo: boolean;}</code> but in this case <code>{ bar : number }</code></p>