title: Typescript + jQuery: correct way to use event state?
body: <p>I have some simple popstate code for an SPA as follows:</p>
  
  <pre><code>module myModule {
      $(function () {
          $(window).on("popstate", function(e) {
              if (e.originalEvent.state !== null) {
                  // code removed
              }
          });
      });
  }
  </code></pre>
  
  <p>(The use of originalEvent is due to answers like this: <a href="https://stackoverflow.com/questions/7860960/popstate-returns-event-state-is-undefined">popstate returns event.state is undefined</a>)</p>
  
  <p>This gives a compile error: </p>
  
  <blockquote>
    <p>Property 'state' does not exist on type 'Event'.</p>
  </blockquote>
  
  <p>e is a JQueryEventObject type and originalEvent is an Event type.</p>
  
  <p>Now I've managed to work around the problem by defining this interface:</p>
  
  <pre><code>interface EventWithState extends Event {
      state: any;
  }
  </code></pre>
  
  <p>(*I doubt "any" is really my best option here - if anyone knows what type state should be let me know, and more importantly how do I find that out for myself in such cases)</p>
  
  <p>And I changed my above code like so:</p>
  
  <pre><code>module myModule {
      $(function () {
          $(window).on("popstate", function(e) {
              if ((&lt;EventWithState&gt;e.originalEvent).state !== null) {
                  // code removed
              }
          });
      });
  }
  </code></pre>
  
  <p>OK that works fine now and compiles to the original code I wanted.   But it seems like an awkward workaround.</p>
  
  <p>Is this the acceptable method to do this?  Is something missing from typescript definitions?  Or is there something I am missing.</p>
  
  <p>Furthermore using <code>e.state</code> also doesn't work, however editing jquery.d.ts (from DefinitelyTyped) and adding <code>state: any;</code> to BaseJQueryEventObject fixes it in a similar way to my workaround.   This is what makes me think something is missing from definitions for typescript regarding the Event state.</p>