title: Prevent the use of a method in another method
body: <p>I want to prevent the use of one method (<code>baz</code>) in another method (<code>bar</code>) with types alone, because this is undesirable for some reason, e.g. causes infinite recursion. I would prefer to avoid runtime checks.</p>
  
  <p>This works but requires to specify <code>this</code> in implementation, a developer who writes <code>Foo</code> should be aware of the restriction:</p>
  
  <pre><code>abstract class AbstractFoo {
      abstract bar(): void;
  
      baz() {
          this.bar();
      }
  } 
  
  class Foo extends AbstractFoo {
      bar&lt;T extends this &amp; { baz: never }&gt;(this: T) {
          this.baz(); // restriction exists here
      }
  }
  </code></pre>
  
  <p>I would like to infer <code>this</code> that restricts the use of <code>baz</code> in <code>bar</code>, this doesn't work:</p>
  
  <pre><code>abstract class AbstractFoo {
      abstract bar&lt;T extends this &amp; { baz: never }&gt;(this: T): void;
  
      baz() {
          (this as any).bar(); // restriction exists here
      }
  } 
  
  class Foo extends AbstractFoo {
      bar() {
          this.baz(); // restriction doesn't exist here
      }
  }
  </code></pre>
  
  <p>The objective is to notify a developer who isn't aware of the restriction with type check, so snippet 1 isn't a good option.</p>
  
  <p>Can this restriction be imposed with inheritance or in some other way that wouldn't require to specify <code>this</code> type in <code>Foo</code> implementation?</p>
  
  <p>If there are blocking TypeScript issues that can be tracked for progress, references are welcome.</p>