I'm doing an operation on an array like this:
.filter(key => actions && actions[key])
.forEach(key => actions[key](event, dispatch));
But I'm getting a TypeScript error on the forEach
actions
: Object is possibly 'undefined'
.
Yet it can't be 'undefined'
as it is filtered for those entries that do have actions
.