xxxxxxxxxx
var key = "happyCount";
var obj = {};
obj[key] = someValueArray;
xxxxxxxxxx
interface MyObject {
[key: string]: any;
}
// Usage example:
const myObject: MyObject = {
key1: "value1",
key2: "value2",
};
// Accessing values
console.log(myObject.key1); // Output: "value1"
console.log(myObject.key2); // Output: "value2"
xxxxxxxxxx
enum Options {
ONE = 'one',
TWO = 'two',
THREE = 'three',
}
interface OptionRequirement {
someBool: boolean;
someString: string;
}
type OptionRequirements = {
[key in Options]: OptionRequirement; // Note that "key in".
}