title: Typescript 2: Custom Type definition in node_modules
body: <p>Let's say I publish a custom library called <code>my-library</code>. This library will be of the structure</p>
  
  <pre><code>node_modules/
      my-library/
          lib/
              index.js
              src/
                ...
          typings/
              index.d.ts
          package.json
  </code></pre>
  
  <p>Say now I export default something called <code>Application</code> from the index.js, so you use it by <code>import Application from 'my-library';</code></p>
  
  <p>Now, in my <code>index.d.ts</code> I want to declare its typing:</p>
  
  <pre><code>export = Application;
  export as namespace Application;
  
  declare namespace Application {
     function foo(arg1: string): object;
  }
  </code></pre>
  
  <p>I know expect this to return an error but it does not:</p>
  
  <pre><code>import Application from 'my-library';
  
  Application.foo(123)[0].blahblah;
  </code></pre>
  
  <p>Not only is the argument wrong, but so is the use of the return value. I don't know how I am supposed to add my type definitions so that the above works.</p>