I need to
type A {
f1: string;
f2; string;
}
By other side I have a variable contains the field name:
let fieldName: string = "f2";
I'd like to create an object using fieldName:
{"content of fieldName": "sdf"}
Any ideas?
As of ES2015 you can use computed properties.
For your example that would mean:
{ [fieldName]: "sdf" }