TypeScript Version:
3853bb8 (master after merging #7140 )
Code
class Prop {
value: any;
}
var x: Prop | null = null;
if (x === null) {
;
}
else if (x.value === null) { // Line 9
x = null;
}
tsc -t es5 --strictNullChecks ./foo.ts
Expected behavior:
Compiles.
Actual behavior:
foo.ts(9,10): error TS2531: Object is possibly 'null' or 'undefined'.
If the x = null; assignment (line 10) is removed, it does compile, and x is correctly inferred to be non-null in the condition and body of the else-if block. But this assignment should not have any effect on the nullability of x in the else-if condition.