title: How do I enforce a function type interface on a class method in typescript?
body: <p>Many methods of the <code>class</code> I'm writing implicitly have the same <a href="https://www.typescriptlang.org/docs/handbook/interfaces.html#function-types" rel="nofollow noreferrer">function type</a>. What I want to do is enforce this function type so that I can explicitly state that certain methods must conform to the function type.</p>
  <p>e.g.</p>
  <pre><code>interface MyFunctionType {(resource: string | Resource): Something}
  </code></pre>
  <p>and my class has some methods that conform to this interface.</p>
  <pre><code>class MyClass {
      // ...
  
      someMethod() { /*...*/ }
  
      someMethodThatConforms(resource: string | Resource) {
          // ...
          return new Something(/*...*/);
      }
  
      anotherMethodThatConforms(resource: string | Resource) {
          // ...
          return new Something(/*...*/);
      }
  
      someOtherMethod() { /*...*/ }
  
      // ...
  }
  </code></pre>
  <p>I know that <code>someMethodThatConforms</code> and <code>anotherMethodThatConforms</code> conform to the interface but now I want to know how do I <em>assert</em> that <code>someMethodThatConforms</code> and <code>anotherMethodThatConforms</code> must conform the interface <code>MyFunctionType</code> (so that if I change, <code>MyFunctionType</code> errors are thrown)?</p>