title: Typescript export syntax & code structuring
body: <p>I'm building a typescript library, and I would like to do it the following way:</p>
  
  <ol>
  <li>One <code>class</code> (<code>interface</code>) / file in the dev sources</li>
  <li>Since the whole library "belongs together", all can go under 1 namespace</li>
  <li>When building, I want to be able to create a single output <code>js</code> and <code>d.ts</code> file, only with the relevant exports/definitions.</li>
  </ol>
  
  <p>The way I tried to do is the following:</p>
  
  <p>I used the <code>/// &lt;reference path="..." /&gt;</code> syntax, to reference other files</p>
  
  <p><strong>Foo.ts</strong> </p>
  
  <pre><code>class Foo {
      // stuff
  }
  </code></pre>
  
  <p><strong>Bar.ts</strong></p>
  
  <pre><code>/// &lt;reference path="Foo" /&gt;
  
  class Bar extends Foo {
      // just an example for referencing another compilation unit
  }
  </code></pre>
  
  <p>Create a <code>tsconfig.json</code> file, which uses the <code>out</code> option, so everything is concatenated into a single file:</p>
  
  <pre><code>{
      "compilerOptions": {
          "module": "commonjs",
          "target": "ES5",
          "out": "src-gen/app.js"
          /* other options ... */
      }
  }
  </code></pre>
  
  <p>And finally add a single file, which exports all the stuff, what I want to be able to import from other files, like this:</p>
  
  <p><strong>Exports.ts</strong></p>
  
  <pre><code>/// &lt;reference path="Bar" /&gt;
  
  export {Bar} // don't want to expose Foo, since its not relevant for users of the lib.
  </code></pre>
  
  <p>But the <code>export {Bar}</code> line gives the following compile error: </p>
  
  <blockquote>
    <p>Circular definition of import alias 'Bar'. import Bar</p>
  </blockquote>
  
  <p>I have no idea, what this error means, since <code>Bar</code> is not imported anywhere, only referenced using the <code>/// &lt;reference&gt;</code> syntax.</p>
  
  <p>My whole goal at the end is, to have a single file, <code>js</code> file as output, which looks like this:</p>
  
  <pre><code>/* compiled js source of Foo */
  
  /* compiled js source of Bar */
  
  exports = {
      Bar
  }
  </code></pre>
  
  <p>My question(s) are:</p>
  
  <ol>
  <li>Is this a valid way to do things?</li>
  <li>If yes, what's the problem with <code>export {Bar}</code></li>
  <li>If no, how would you achieve, what I want to do?</li>
  </ol>
  
  <p>Thanks in advance, for any help/advice!</p>