title: Simulate dataTransfer for drag events in TypeScript
body: <p>I am writing unit tests for a drag and drop interaction that relies on the <code>dataTransfer</code> of the event. Also I am using typescript. To simulate the event(s) I wrote this little function:</p>
  
  <pre><code>function createDragEvent(eventName: string, dataTransferData?: Array&lt;any&gt;) {
      const event = new CustomEvent(eventName, { bubbles: true, cancelable: true });
      event.dataTransfer = {
          setData: jasmine.createSpy("setData() spy"),
          getData: jasmine.createSpy("getData() spy").and.callFake(function() {
              return dataTransferData[0] === 'text/plain' ? dataTransferData[1] : undefined;
          })
      };
      return event;
  }
  </code></pre>
  
  <p>However, TypeScript tells me</p>
  
  <blockquote>
    <p>TS2339: Property 'dataTransfer' does not exist on type 'CustomEvent'.</p>
  </blockquote>
  
  <p>I cannot <em>not</em>  use the <code>dataTransfer</code> and I cannot use native <code>DragEvent</code>s because I cannot set the data or spy on its functions. Is there a way to deal with this, e.g. tell TypeScript that <code>dataTransfer</code> is ok or disable the error for this file or something like that?</p>