title: Typing Object.fromEntries(new FormData(form))
body: <p>TypeScript newbie here, having problems with <code>Object.fromEntries</code>. I'm trying to pares form and cast its values to something else. For example, given homogeneous shape of all data being strings, below works:</p>
  <pre><code>
  // example form content:
  // {
  //    foo: 'bar',
  //    bar: 'biz'
  //  }
  //  return values
  // {
  //    foo: 'bar',
  //    bar: 'biz'
  //  }
  
  export const getFormData = (form: HTMLFormElement) =&gt; {
    return Object.fromEntries&lt;string&gt;(
      new FormData(form) as Iterable&lt;[PropertyKey, string]&gt;,
    )
  }
  </code></pre>
  <p>How I can cast values returned from the above to values others than strings? For example:</p>
  <pre><code>
  // example form content:
  // {
  //    foo: '1',
  //    bar: 'biz',
  //    biz: 'false'
  //  }
  //  desired return values
  // {
  //    foo: 1,
  //    bar: 'biz',
  //    biz: false
  //  }
  
  export const getFormData = (form: HTMLFormElement) =&gt; {
    return Object.fromEntries&lt;string&gt;(
      new FormData(form) as Iterable&lt;[PropertyKey, string]&gt;,
    )
  }
  </code></pre>
  <p>My feeling is that I can <em>somehow</em> fix it with generics and interfaces but I'm at a loss how to proceed. If someone could ELI5 I would be grateful.</p>
  <p>EDIT: my <code>tsconfig.json</code>:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;compilerOptions&quot;: {
          &quot;moduleResolution&quot;: &quot;node&quot;,
          &quot;module&quot;: &quot;es2020&quot;,
          &quot;lib&quot;: [&quot;esnext&quot;, &quot;dom&quot;, &quot;dom.iterable&quot;],
          &quot;target&quot;: &quot;es2020&quot;,
          &quot;downlevelIteration&quot;: true,
          &quot;importsNotUsedAsValues&quot;: &quot;error&quot;,
          &quot;preserveValueImports&quot;: true,
          &quot;isolatedModules&quot;: true,
          &quot;resolveJsonModule&quot;: true,
          &quot;sourceMap&quot;: true,
          &quot;esModuleInterop&quot;: true,
          &quot;skipLibCheck&quot;: true,
          &quot;forceConsistentCasingInFileNames&quot;: true,
          &quot;baseUrl&quot;: &quot;.&quot;,
          &quot;allowJs&quot;: true,
          &quot;checkJs&quot;: true,
      }
  }
  </code></pre>
  <p>EDIT2: Better explanation of the desired outcome.</p>