title: How to export a class instance in Typescript
body: <p>Im authoring a TS library, and would like to export an instance of a class, I intend for it be used as singleton in the consuming application.</p>
  
  <p>Right now I have the following structure:</p>
  
  <p><strong>index.ts</strong></p>
  
  <pre><code>export { Foo } from './my-class';
  </code></pre>
  
  <p><strong>foo.ts</strong></p>
  
  <pre><code>export class Foo {
    functionA() {}
  }
  </code></pre>
  
  <p>I'm then building into UMD format using webpack and babel, and in another application (Angular), I am able to import in my class, instantiate it and use it accordingly.</p>
  
  <pre><code>import { Foo } from 'foo';
  
  private foo = new Foo();
  
  const x = foo.functionA();
  </code></pre>
  
  <p>Is there a way to return an instantiated instance of my class or am I thinking about this the wrong way?</p>
  
  <p>So instead of having to do <code>new Foo()</code>, the imported Foo would actually already be an instance?</p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE</strong>
  I should have mentioned, I am exporting other things such as interfaces, so I don't think a default class export would be the right way to go correct? - see <a href="https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html" rel="noreferrer">here</a></p>