title: TypeScript - how to type a self-instantiating function
body: <p>Function Register is instantiated by calling <code>Register('something')</code>. Typescript says this is only possible if <code>new</code> is used on a <code>void</code> returning function . In this case <code>Register</code> is returning an instance of itself. How should I type this in Typescript?</p>
  
  <pre><code>module Register {
  
     export function Register(x: string): Instance {
        if (!(this instanceof Register)) {
            return new Register(x)
        }
        this.value = x
     }
     ...
  
     export interface Instance {
        new(x: string): Instance;
        ...
     }
  
  }
  export = Register
  </code></pre>