title: Typescript module factory pattern
body: <p>There is a well-known approach in node.js to leverage the module factory pattern. For, example:</p>
  
  <p>m.js</p>
  
  <pre><code>function factoryMethod(module) {
    // doing some stuff and returning object initialized with module parameter
  }
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>var o = require('./m')(module);
  // using o
  </code></pre>
  
  <p>How can I do the same in typescript. Actually, creating m.ts is not a problem:</p>
  
  <p>m.ts</p>
  
  <pre><code>function factoryMethod(module: NodeModule): any {
    // doing some stuff
  }
  
  export = factoryMethod;
  </code></pre>
  
  <p>But how should I use import syntax to use this module factory method like in javascript?</p>