title: Nested Typescript Map Type
body: <p>With Typescript 4.5.0, I can't seem to get the type of values to compile. For the following:</p>
  <pre><code>type foo = 'a' | 'b'
  
  const x: Map&lt;foo, {[key: string]: string}&gt; = new Map([
    ['a', {'ok': 'so'}],
    ['b', {'nah': 'right'}]
  ])
  </code></pre>
  <p>tsc barfs up</p>
  <pre><code>const x: Map&lt;foo, {
      [key: string]: string;
  }&gt;
  Type 'Map&lt;&quot;a&quot; | &quot;b&quot;, { 'ok': string; 'nah'?: undefined; } | { 'nah': string; 'ok'?: undefined; }&gt;' is not assignable to type 'Map&lt;foo, { [key: string]: string; }&gt;'.
    Type '{ 'ok': string; 'nah'?: undefined; } | { 'nah': string; 'ok'?: undefined; }' is not assignable to type '{ [key: string]: string; }'.
      Type '{ 'ok': string; 'nah'?: undefined; }' is not assignable to type '{ [key: string]: string; }'.
        Property ''nah'' is incompatible with index signature.
          Type 'undefined' is not assignable to type 'string'.
  </code></pre>
  <p>Is this a compiler bug, or am I doing something wrong to make the Map's value generic look like a union type?</p>
  <p><a href="https://www.typescriptlang.org/play/#code/C4TwDgpgBAZg9nKBeKByAhqqAfNAjVAKEIGM4A7AZ2CgA8AuKAWXTAB544AaKAbwG0A1hBCNqAJwCW5AOYBdMcCmyAvgD5kUchADuzVgAp+hKFH4ZUPXqjiDUjVJTioVcribOoCV1OXQALezQpGX9gFzlCOQBKIA" rel="nofollow noreferrer">A link to the typescript playground </a></p>