title: Typescript: Work around type definition error for javascript builtin
body: <p>I want to use <a href="https://developer.mozilla.org/en-US/docs/Web/API/FormData" rel="noreferrer">FormData</a> in typescript.  Unfortunately, the <a href="https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.generated.d.ts#L10208" rel="noreferrer">generated typescript definition files</a> doesn't support a FormData constructor with a Form Element as detailed in  <a href="https://github.com/Microsoft/TypeScript/issues/1074" rel="noreferrer">Typescript Issue #1074</a>.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>var formEl = &lt;HTMLFormElement&gt; document.getElementById("myForm");
  var formData = new FormData(formEl);
  </code></pre>
  
  <p>The code gives the following error because the <a href="https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.generated.d.ts#L10208" rel="noreferrer">generated definition</a> is wrong:</p>
  
  <blockquote>
    <p>error TS2346: Supplied parameters do not match any signature of call target.</p>
  </blockquote>
  
  <p>I want to use the following declaration:</p>
  
  <pre><code>declare var FormData: {
      prototype: FormData;
      new (form?: HTMLFormElement): FormData;
  }
  </code></pre>
  
  <p>But, if I include that type definition, I get this error:</p>
  
  <blockquote>
    <p>error TS2403: Subsequent variable declarations must have the same type.  Variable 'FormData' must be of type '{ new (): FormData; prototype: FormData; }', but here has type '{ new (form?: HTMLFormElement): FormData; prototype: FormData; }'.</p>
  </blockquote>
  
  <p>How can I work around this issue?</p>