title: Typescript: calling a function using a string parameter as function name produces compiler error - "Element implicitly has an 'any' type"
body: <p>I am having a problem trying to find a way to select a function to call based on passed string parameter.
  I have looked at similar questions like <a href="https://stackoverflow.com/questions/57086672/element-implicitly-has-an-any-type-because-expression-of-type-string-cant-b">Element implicitly has an &#39;any&#39; type because expression of type &#39;string&#39; can&#39;t be used to index</a>, but this one and all the other examples I found are about pointing an array item by index, and not calling a function. I could not apply the solution to my task.</p>
  <p>The expression <code>this[detail.activity]</code> produces exception:  &quot;Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ dispatch: ... &quot;.</p>
  <pre><code>export class DataModel{
      public activity: string = '';
      public name: string = '';
  }
  
  
  export class CallbackComponent implements OnInit {
  
    constructor() { }
  
    ngOnInit(): void {
      const data: Array&lt;DataModel&gt; = [
        {
          name: &quot;dataProcessing1_name&quot;,
          activity: &quot;dataProcessing1&quot;
        },
        {
          name: &quot;dataProcessing2_name&quot;,
          activity: &quot;dataProcessing2&quot;
        }
      ];
      this.dataView(data);
    }
  
    dataView(data: DataModel[]) {
  
      let detailDispatcher = {
  
        dispatch: function (detail: DataModel): void{
          var method;
          Object.keys(this).map((k,i)=&gt;{  
            //method = this[k];
            if (k == detail.activity) {
              method = this[k];
              return method.call(this, detail);
            }
          })
        },
  
        dataProcessing1: (detail: DataModel) =&gt; {
          console.log(&quot;dataProcessing 1&quot;);
        },
        dataProcessing2: (detail: DataModel) =&gt; {
          console.log(&quot;dataProcessing 2&quot;);
        },
        dataProcessing3: (detail: DataModel) =&gt; {
          console.log(&quot;dataProcessing 3&quot;);
        },
      };
  
      return data.map((detail: DataModel) =&gt; {
        detailDispatcher.dispatch(detail);
      })
    }
  }
  </code></pre>
  <p>Can anyone help me to find a solution?</p>