title: TypeScript class per file in same namespace in Node.js
body: <p>What is the pattern for one class per file where multiple classes (and therefore multiple files) contribute to the same namespace? I'm asking this specifically in a Node.js context.</p>
  
  <p>I know how to define one class per file in the same namespace:</p>
  
  <p><em>foo/A.ts:</em></p>
  
  <pre><code>module foo {
      export class A {
      }
  }
  </code></pre>
  
  <p><em>foo/B.ts:</em></p>
  
  <pre><code>module foo {
      export class B {
      }
  }
  </code></pre>
  
  <p><em>main.ts:</em></p>
  
  <pre><code>/// &lt;reference path="./foo/A.ts"/&gt;
  /// &lt;reference path="./foo/B.ts"/&gt;
  
  // TODO: How do I import the foo namespace at runtime?
  </code></pre>
  
  <p>TypeScript is supposedly a language for application-scale JavaScript development, yet we seem to be left out in the cold on <strong>the</strong> most fundamental aspect of application-scale development, which is how to layout and structure code files and how everything is linked together at runtime.</p>