How would I access a field/property of an interface with a string that represents the field in Typescript.
For instance, if we have a interface such as,
export interface foo {
field1: boolean;
field2: boolean;
where foo.field1 = true
I want to create a command that returns the value of a field such as,
public findValue(f: string): boolean {
return foo.f;
}
However, ^ of course this does not work since f
is a string. But is there a way to do this in Typescript?