title: TypeScript: Infer parameter values from constructor and use it as type checking on class method's parameter
body: <p>Not sure if this is possible, but I'm looking for a way to allow TypeScript to automatically infer a class constructor's argument values, then use the inferred values to type-check another parameter of a class method.</p>
  <p>For example:</p>
  <pre class="lang-js prettyprint-override"><code>class MyClass {
    // aim: to infer the string values from the rest parameter param2
    constructor(param1: number, ...param2: string[]) {
      console.log(param1);
      console.log(param2);
    }
  
    // param uses values inferred from param2
    classMethod(param) {
      console.log(param);
    }
  }
  </code></pre>
  <p>The aim is to allow TypeScript to infer values from <code>param2</code> then apply it onto <code>classMethod</code>'s <code>param</code>. For example:</p>
  <pre class="lang-js prettyprint-override"><code>const myClass = new MyClass( 0, 'a', 'b', 'c' );
  myClass.classMethod('a') // shall be correct
  myClass.classMethod('x') // TypeScript shall highlight this with red wavy line
  </code></pre>
  <p>I've tried using generic, but ultimately confused on how to infer values from generic <code>T</code> which extends a string array. For example:</p>
  <pre class="lang-js prettyprint-override"><code>class MyClass&lt;T extends string[] = []&gt; {
    constructor(param1: number, ...param2: T) {
      // things
    }
  
    // how do I infer the array values in T?
    classMethod(param) {
      console.log(param);
    }
  }
  </code></pre>
  <p>Perhaps I'm still lacking of some steps to correctly infer the values from the generic. Will this be possible? Thank you in advance!</p>