Q: Assign object members to context menu command - TypeScript I need to replace string in JSON to functions (object methods) with the corresponding name and pass an argument to it
but got 
"Type 'this[Extract<keyof this, string>]' is not assignable to type '(event?: any) => void'"

In short, would like to have something like:


if (typeof this[key] === 'function') {
    position.command = this[key];
}


But my solution does not let me pass arguments to it

A: Try this. Also note that this is dangerous since every function will be assigned to command on this.
  id = 1;
  name = 'alice';

  position = {
    command: null
  }

  ngOnInit() {
    for (const key in this) {
      console.log(key);

      if (typeof this[key] === 'function') {
          this.position.command = this[key];
      }
    }
  }

  someFunction() {
    console.log('someFunction');
  }

See this stackblitz it doesn't give any error. 
Error is only there if you initialize command with a string; eg. command: ''
