There is an object in my possession and the goal is to dynamically invoke a method on it.
It would be ideal to have typechecking, although that may prove to be unattainable. Unfortunately, the current situation is that I cannot even get it to compile:
const key: string = 'someMethod'
const func = this[key]
func(msgIn)
leads to the following error message...
Element implicitly has an 'any' type
because expression of type 'any' can't be used
to index type 'TixBot'.
I experimented with other type options but none were successful.
const key: any = cmd.func
const func: any = this[key]
Aside from @ts-ignore
, are there alternative solutions? I am considering utilizing .call()
or bind
as potential workarounds?