title: Why can't TypeScript infer a generic type when it is in a nested object?
body: <p>I've got a type that TypeScript can't infer the generic of.</p>
  
  <pre><code>interface Foo&lt;A&gt; {
      [name: string] : {
          foo : A
      }
  }
  
  function makeFoo&lt;A&gt;(foo: Foo&lt;A&gt;) : Foo&lt;A&gt;{
      return foo
  }
  
  // Works fine when manually specifying the types
  const manuallyTyped : Foo&lt;string | number&gt; = {
      a: {
          foo: '1'
      },
      b: {
          foo: 3
      }
  }
  
  // ERROR, Can't infer type as Foo&lt;string | number&gt;
  makeFoo({
      a: {
          foo: '1'
      },
      b: {
          foo: 3
      }
  })
  </code></pre>
  
  <p>Originally, I was using the type below but I wanted to make the values of the object objects themselves. Inference works just fine when the indexed signature is flat.</p>
  
  <pre><code>interface FlatFoo&lt;B&gt; {
      [name: string] : B
  }
  
  function makeFlatFoo&lt;B&gt;(bar: FlatFoo&lt;B&gt;): FlatFoo&lt;B&gt;{
      return bar
  }
  
  // Correctly has type FlatFoo&lt;string | number&gt;
  const inferred = makeBar({
      a: 'a',
      b: 2
  })
  </code></pre>
  
  <p>Does anyone have an explanation and/or a recommendation for getting this to work?</p>