title: Convert Record to Map in type safe way - TypeScript
body: <p>This is my function that converts record to map:</p>
  <pre><code>type MyReturn&lt;Str&gt; = Map&lt;Str, Map&lt;number, number&gt;&gt;;
  export const mapRecordToMap = &lt;MyString extends string&gt;(data: Record&lt;MyString, [number, number][]&gt;)
      : MyReturn&lt;MyString&gt; =&gt; {
          const myReturn = new Map&lt;MyString, Map&lt;number, number&gt;&gt;();
          Object.entries(data).forEach(([key, value]) =&gt; {
              myReturn.set(key as MyString, new Map(value as [number, number][]));
          });
          
          return myReturn;
  };
  </code></pre>
  <p>The problem I have is that I have to use <code>'as'</code> here:</p>
  <pre><code>myReturn.set(key as MyString, new Map(value as [number, number][]));
  </code></pre>
  <p>to have proper type checking. How to avoid that?</p>
  <p>Thanks!</p>