title: How can I return a class from a TypeScript function?
body: <p>I'm using TypeScript with a dependency injection library which works very similar to Angular 1 - basically: <em>register a factory with your dependencies as arguments</em>.</p>
  
  <p>This is how I would register a class in ES6</p>
  
  <pre><code>export let factory = () =&gt; {
      return class Foo {}
  };
  </code></pre>
  
  <p>If I write the same in TypeScript:</p>
  
  <pre><code>export let factory = () =&gt; {
      return class Foo {}
  };
  </code></pre>
  
  <p>It fails to compile with the error</p>
  
  <blockquote>
    <p>error TS4025: Exported variable 'factory' has or is using private name 'Foo'.</p>
  </blockquote>
  
  <p>Is there any way to allow TypeScript to return a class from a factory function?</p>