title: 'Class' is referenced directly or indirectly in its own type annotation
body: <p>Here is basic DI pattern:</p>
  
  <pre><code>class Foo {
    foo = 1;
  }
  
  class Bar {
    constructor(public Foo: typeof Foo) {
      const foo = new Foo();
    }
  }
  
  class Baz extends Foo {}
  new Bar(Baz);
  </code></pre>
  
  <p>It gives an error:</p>
  
  <blockquote>
    <p>'Foo' is referenced directly or indirectly in its own type annotation.</p>
  </blockquote>
  
  <p>But it clearly isn't self-referential, because <code>public Foo</code> is property name, and <code>typeof Foo</code> is type.</p>
  
  <p>What is going on here? Is it TypeScript bug that is expected to be solved in future? Is it documented?</p>
  
  <p>Can <code>Foo</code> property name be kept somehow here without renaming it? It just makes sense to name it so.</p>
  
  <hr>
  
  <p>It appears that <code>public Foo: Foo</code> doesn't create problems with types, and <code>Foo</code> refers to original <code>Foo</code> interface in <code>public AnotherFoo: Foo</code>:</p>
  
  <pre><code>class Bar {
    constructor(public Foo: Foo, public AnotherFoo: Foo) {
      const foo: Foo = AnotherFoo;
      foo.foo;
    }
  }
  </code></pre>
  
  <p>And  <code>typeof Foo</code> refers to <code>Foo</code> parameter type and not original <code>Foo</code> interface:</p>
  
  <pre><code>class Bar {
    constructor(public Foo: number, Quux: typeof Foo) {
      const quux: number = Quux; 
    }
  }
  </code></pre>