title: How can I write a Typescript factory method to avoid the `new` keyword?
body: <p>I enjoy Scala's case-class syntax, particularly elimination of the <code>new</code> keyword during instantiation. I'd like to do something similar in Typescript:</p>
  <pre><code>// Pizza.ts
  class Pizza {
    constructor(name: string)
    bake(): string { return `delicious ${name} pizza` }
  }
  
  export default function(name: string) { return new Pizza(name) }
  </code></pre>
  <pre><code>&gt;&gt; Pizza('pineapple').bake()
  'delicious pineapple pizza'
  </code></pre>
  <p>This works fine. But what if I try to define a generic method for doing this operation on any class?</p>
  <pre><code>// AdvancedTechnology.ts
  export function newless&lt;C&gt;(c: {new(...args: any[]): C}) {
    return function(...args: any[]): C { return new c(...args) }
  }
  </code></pre>
  <pre><code>// Pizza.ts
  class Pizza { ... }
  export default newless(Pizza)
  </code></pre>
  <p>This also works, but does not correctly preserve the type of the <code>Pizza</code> class; the compiler no longer knows about the <code>bake</code> method.</p>
  <p>Is there a way to write <code>newless</code> so that the resulting class has the correct type?</p>