title: Using Leaflet or any js library with Typescript and webpack
body: <p><em><strong>Note:</strong></em> I have searched a lot but I couldn't find my answer.</p>
  <p>I am trying to create a map library by extending <code>leaflet</code>. But I think my problem is with using <code>js</code> libraries in general. I am using <code>webpack</code> and <code>ts-loader</code> to create the output file.</p>
  <p>I have installed the types <code>@types/geojson</code> and <code>@types/leaflet</code> and moved them to <em>modules</em> folder.</p>
  <p>here is my simple Test1.ts file :</p>
  <pre><code>import * as L from './modules/@types/leaflet/index';
  import { MyDataItem } from './MyDataItem ';
  
  export class Test1 {
      text: string;
      data: MyDataItem ;
      latLng: L.LatLng;
     
      constructor(theName: string) {
          this.data = { name: theName} as MyDataItem ;
      }
      public show() {
          console.log(this.data.name);
      }
  
      public showLatLng() {
          this.latLng = new L.LatLng(22, 55);
          console.log(this.latLng);
      }
  }
  
  module.exports = {
      Test1: Test1
  }
  </code></pre>
  <p>I set <code>library:'lib'</code> in my webpack output option.
  now I call the following methods from my browser console:</p>
  <pre><code>&gt; (new lib.Test1(&quot;aa&quot;)).show()        // result: aa
  &gt; (new lib.Test1(&quot;aa&quot;)).showLatLng()   // error : L.LatLng is not a constructor
  // or if it set webpack optimization:minimize to true  the error is: i.LatLng is not a constructor
  </code></pre>
  <p>I have added <code>leaflet.js</code> to the page so <code>typeof(L.latlng)</code> is <code>&quot;function&quot;</code> (<code>latlng</code> with small letters).</p>
  <p><strong>Question:</strong> obviously the types that I used from leaflet are not accessible after generating js files. My assumption was if you create ts declaration file (<strong>.d.ts</strong>) for any <strong>js</strong> library you can use that library in your ts files. what am I missing here? How to add and use normal js libraries in <code>Typescript</code> file so that they work after bundling them with <code>webpack</code>?</p>