title: Return type of a function based on param name
body: <p>Let's say I have an interface <code>MyInterface</code> like this:</p>
  
  <pre><code>interface MyInterface = {
      param1: string;
      param2: number;
  }
  </code></pre>
  
  <p>Is there a way declare the return type of a function, given that the value of the parameter of the function is in itself a parameter of <code>MyInterface</code>:</p>
  
  <pre><code>class MyClass&lt;T = MyInterface&gt; {
     constructor(private params: T) {
       // ...
     }
  
      // The question comes here:
     get(value: keyof T): T[value] { // Obviously this doesn't work
        return this.params[value];
     }
  }
  </code></pre>