If aggregatedRules has a key, its value will be an array of strings always.
function aggregateLabelsByRule (rules: LabelingRule[]): { [key in LabelingAction]?: string[] } {
const aggregatedRules: { [key in LabelingAction]?: string[] } = {}
for(const rule of rules) {
if(rule.action in aggregatedRules) {
aggregatedRules[rule.action].push(...rule.labels)
} else {
aggregatedRules[rule.action] = rule.labels
}
}
return aggregatedRules
}
src/validateConfig.ts:12:7 - error TS2532: Object is possibly 'undefined'.
12 aggregatedRules[rule.action].push(...rule.labels)