title: How to register event handlers for TypeScript declarations
body: <p>I've asked this question on typescript's codeplex forums but didn't get an answer so I'm asking here. For a given TypeScript class declaration, for example the Bing Maps one (<a href="https://bingmapsts.codeplex.com/" rel="nofollow">https://bingmapsts.codeplex.com/</a>) how would someone register an event handler?</p>
  
  <p>On the Map class (in Microsoft.Maps.d.ts) there are a couple of events declared:</p>
  
  <pre><code>viewchange: () =&gt; any;
  viewchangeend: () =&gt; any;
  viewchangestart: () =&gt; any;
  </code></pre>
  
  <p>And I've tried hooking a function like the following inside a typescript file but it never gets called:</p>
  
  <pre><code>///&lt;reference path="Bing/Microsoft.Maps.All.d.ts" /&gt;
  
  window.onload = function()
  {
      var map = new Microsoft.Maps.Map(document.getElementById('map'),
          {
              backgroundColor: 0,                
          });
  
      map.click = () =&gt; alert('click');
      map.viewchangestart = () =&gt; alert('viewchangestart');
  }
  </code></pre>
  
  <p>In traditional javascript, I would use the following:</p>
  
  <pre><code>Microsoft.Maps.Events.addHandler(map, 'viewchangestart', function (e)
      {
          alert('viewchangestart');
      });
  </code></pre>
  
  <p>but there is no such method in the typescript declaration and since I can't seem to reference the virtual earth map control from a .ts file I'm not sure how I can do this.</p>