I need in typescript (or, at least, javascript) a function which I can call/use like an array: myFunc[someInput]
I know I cand do something like:
interface IInputs {
"someInput1": someType,
"someInput2": someType,
}
interface someType {
// ...
}
var myFunc: IInputs;
So I may write:
myFunc["someInput1"]
The first problem is that I have to hard code each possible input. Input is a string but can be any string. Another is that my function should call another one (a 'normal' one) simply like this:
myFunc[input: string] : any {
//...
return anotherFunc(input);
}
I have simplified my problem to show only the relevant facts.