title: Map of Maps in Typescript / ECMAScript
body: <p>This is what i personally would consider correct in various languages, but here it is not. I must be ignorant of an aspect of Typescript, but I can not so easy determine where the gap is.</p>
  <p>The implementation requires a map of maps. The top map is a string key, and the a map of string-keys and string-values.</p>
  <pre><code>class aClass
  {
      myMap: Map&lt;string, Map&lt;string, string&gt;&gt;;
  
      constructor ()
      {
          this.myMap = new Map&lt;string, Map&lt;string, string&gt;&gt;([
              [&quot;key1&quot;, new Map&lt;string,string&gt;()],
              [&quot;key2&quot;, new Map&lt;string,string&gt;()]
          ]);
      }
  
      async aTask(map: Map&lt;string,string&gt;)
      {
          map.set(&quot;subKey1&quot;, &quot;VALUE&quot;);
      }
  
      async someWork()
      {
          this.aTask(this.myMap[&quot;key1&quot;]);
          this.aTask(this.myMap.get(&quot;key1&quot;));
      }
  }
  </code></pre>
  <p>How do I correctly access the Map&lt;string, string&gt;() in the function someWork() ?</p>
  <p>The error for the first accessor : this.aTask(this.myMap[&quot;key1&quot;]);</p>
  <p><em>Element implicitly has an 'any' type because type 'Map&lt;string, Map&lt;string, string&gt;&gt;' has no index signature. Did you mean to call 'get'?</em></p>
  <p>The error for the second accessor : this.aTask(this.myMap.get(&quot;key1&quot;));</p>
  <p><em>Argument of type 'Map&lt;string, string&gt; | undefined' is not assignable to parameter of type 'Map&lt;string, string&gt;'. Type 'undefined' is not assignable to type 'Map&lt;string, string&gt;'.</em></p>