title: TypeScript: Asserting correct this context for a set of imported methods
body: <p>I have class with many methods (~200), which to declutter I've moved to an object on the class, and the actual method definitions to a series of different files.  In order to maintain the correct this context, I import all these methods and bind them accordingly, however TypeScript complains.</p>
  <pre><code>The 'this' context of type 'typeof import(&quot;./methods&quot;)' is not assignable to method's 'this' of type 'Main'.
    Type 'typeof import(&quot;/methods&quot;)' is missing the following properties from type 'Main': name, methods
  </code></pre>
  <p>Example:</p>
  <pre><code>// index.ts
  import * as methods from './methods';
  
  export default class Main {
    constructor(name: string) {
      this.name = name;
    }
  
    name: string;
  
    methods = (Object.keys(methods) as Array&lt;keyof typeof methods&gt;).reduce((acc, k) =&gt; {
      acc[k] = methods[k].bind(this);
      return acc;
    }, {} as typeof methods);
  }
  
  const inst = new Main('Anga');
  inst.methods.DoSomething();
  </code></pre>
  <pre><code>// methods.ts
  import Main from '.';
  
  export function DoSomething(this: Main) {
    console.log(this.name);
  }
  
  export function DoSomethingElse(this: Main, input: string) {
    console.log(`${this.name}: ${input}`);
  }
  
  </code></pre>
  <p>How can I assert that the this context does in fact match after binding?</p>