Imagine having a variable declared with the following type:
test?: boolean | { [key in TestEnum ]: boolean };
Now, let's assign this test
variable within a constant where it can hold either a boolean value or a mapping to an enum. Consider the example below:
EXAMPLE OF SETTING VALUES IN A CONSTANT OBJECT
export const TEST_1 {
name: "Mark",
test: {
[TestEnum.Value1]: false,
[TestEnum.Value2]: true,
[TestEnum.Value3]: true,
[TestEnum.Value4]: true
}
}
};
export const TEST_2 {
name: "Mark",
test: true
}
};
How would one access this test variable in their component when it could be simply test
or test[TestEnum.Value2]
?