title: Typescript: dynamically constructing property name on type
body: <p>Surely this is rudimentary TS, but I can't find the syntax. </p>
  
  <p>I have a type:</p>
  
  <pre><code>type MyType = {
     prop1: string;
     prop2: string;
  }
  </code></pre>
  
  <p>Now inside a function I have a variable of type MyType, but I need to dynamically get the value 
  of a particular property on it, like:</p>
  
  <pre><code>const myMethod = (typeX: MyType, num: number) =&gt; {
      const property1 = typeX['prop${num}`]; // problem line!
  }
  </code></pre>
  
  <p>The typescript error I'm seeing is:</p>
  
  <pre><code>TS7053 Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'MyType'. No index signature with a parameter of type 'string' was found on type 'MyType'
  </code></pre>
  
  <p>Changing it to <code>typeX['prop1']</code> works fine.</p>
  
  <p>How do I cast that string as a property on MyType? </p>