title: Using string literals to get object property with Typescript
body: <p>Fairly new to using Typescript, so forgive if there's a prior example to what my question that I've seen but not understood. I'm trying to <strong>dynamically find the key of an object</strong> in a way that avoids using conditionals to determine which property to get.</p>
  <p>Here is an example of the code:</p>
  <pre class="lang-js prettyprint-override"><code>public buildUrl(appName: string, itemNumber: string) {
    const url: EnvEndpoint = obj[`prefix${appName}`]
    return `${url[process.env.NODE_ENV]}/endpoint/${itemNumber.toString()}`
  }
  </code></pre>
  <p>The key that I want to be dynamic is, which I get an error of the key could be <code>any</code> and is rejected.</p>
  <pre><code>obj[`prefix${appName}`]
  </code></pre>
  <hr />
  <p><em>For further context if at all needed.</em></p>
  <p>The <code>EnvEndpoint</code> is an imported interface that looks like this:</p>
  <pre class="lang-js prettyprint-override"><code>export interface EnvEndpoint {
    [key: string]: string
  }
  </code></pre>
  <p>The <code>obj</code> being imported pulls data that looks like this as an example:</p>
  <pre class="lang-json prettyprint-override"><code>&quot;key&quot;: {
    &quot;dev&quot;: &quot;https://www.google.dev&quot;,
    &quot;qa&quot;: &quot;https://www.google.qa&quot;,
    &quot;uat&quot;: &quot;https://www.google.uat&quot;,
    &quot;prod&quot;: &quot;https://www.google.com&quot;,
  }
  </code></pre>