I am working with an object that looks like this:
enum FeatureNames = {
featureA = 'featureA',
featureB = 'featureB',
featureC = 'featureC'
}
interface FeatureDetails {
on: boolean;
}
type Features = Record<FeatureNames,FeatureDetails>;
const myObj: Features = {
[FeatureNames.featureA]: {
on: true
},
[FeatureNames.featureB]: {
on: false
},
[FeatureNames.featureC]: {
on: false
}
}
How do I go about updating all the values in myObj
so that the on
value is set to true?
If I was not using typescript, I would have used reduce. However, I encountered an error when attempting to do so.
This is the error message I received:
Element implicitly has an 'any' type because an expression of type 'string' cannot be used to index type 'Record'. No index signature with a parameter of type 'string' was found on type 'Record'.ts(7053)