Closed
Description
TypeScript Version: 2.0.0
Code
// strictNullChecks is on
var x: number[] = [];
var y: number = x[0];
y.toString(); // Cannot read property 'toString' of undefined
Expected behavior:
error TS2322: Type 'undefined' is not assignable to type 'number'
Actual behavior:
after compile with command tsc --strictNullChecks
Runtime exception: Cannot read property 'toString' of undefined
I thought strictNullChecks a there to prevent developer from seeing such kind of exceptions in run time.