title: TypeScript constructor overload return different types
body: <p>I have a constructor function that should return a different type based on a param. </p>
  
  <pre><code>interface B {
      hello(): string;
  }
  
  class Foo {  
      constructor(withB: boolean): Foo &amp; B;
      constructor();
      constructor(withB?: boolean) {
          if (withB) {
              Object.assign(this, { hello() {}})
          }
      }
  }
  
  const foo1 = new Foo();
  const foo3 = new Foo(true);
  </code></pre>
  
  <p>But It's not working. How can I do it? </p>