title: How to use optional chaining operator with variable in typescript
body: <p>I have following code and I would like to pass number from value key of variable object, How can I use variable for optional chaining operator for it to solve the error Element implicitly has an <code>any</code> type?</p>
  <pre><code>    function fun(i?: number) {
          console.log(i)
      }
  
      const variable = { min: { value: 1, name: 'google' }, max: {value: 2, name: 'apple'} }
      const variable2 = { min: { value: 1, name: 'google' } }
      const variable3 = { max: {value: 2, name: 'apple'} }
  
      fun(variable?.min.value) // working =&gt; 1
      fun(variable?.max.value) // working =&gt; 2
      fun(variable2?.min.value) // working =&gt; 1
      fun(variable2?.max.value) // working =&gt; undefined
      fun(variable3?.min.value) // working =&gt; undefined
      fun(variable3?.max.value) // working =&gt; 2
  
      Object.keys(variable).forEach((key) =&gt; {
          fun(variable?.[key]?.value) // working but with error Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ min: { value: number; name: string; }; max: { value: number; name: string; }; }'.
      })
  </code></pre>