Closed
Description
TypeScript Version: 2.4.1
Code
// strictNullChecks should be on
let a: number | null = null;
[1].forEach(() => { a = 1; });
if (a !== null) {
console.log(a + 1);
}
Expected behavior:
Output '2'.
Actual behavior:
error TS2365: Operator '+' cannot be applied to types 'never' and '1'.
Actually, after the forEach loop the inferred type of 'a' remains to be 'null', although it may change during the loop.