After upgrading from Angular 7.1.4 to 8.2.0 and Typescript from 3.1.6 to 3.5.3, I encountered an issue with identification of array items.
Prior to the upgrade, TypeScript correctly recognized that the array item was not undefined. However, post-upgrade, I am facing a frustrating compilation error. (Note: I'm using lo-dash here, but similar errors occur with
if (autoCorrectionData[action.algorithmId] !== undefined) {
src/app/state/edit/edit.reducer.ts(417,29): error TS2532: Object is possibly 'undefined'.
How can I make TypeScript acknowledge that the object IS defined after checking it in the if
condition?
*edit* This issue might be related to recent changes in NGRX Dictionaries where dictionary values are allowed to be undefined.