The variable in a for-of loop contains undefined when the target is set to es6. For es5, everything works as expected.
TypeScript Version:
nightly (1.9.0-dev.20160428)
Code
for (const x of ["a", "b"]) {
    x.substring;
}tsconfig.json:
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es6",
        "strictNullChecks": true
    }
}Expected behavior:
Type of x is string in the loop body, no compile error.
Actual behavior:
Type of x is string | undefined, which gives an error.
@ahejlsberg