I have a object 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 can I update the value of every member of myObj so the on value is true?
Without typescript I would just use reduce, but I get a overload error when I try to do so.
Here's the error:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Record'. No index signature with a parameter of type 'string' was found on type 'Record'.ts(7053)
FeatureNames? What'sFeatureDetails? What specific error do you see and in what code?