Open
Description
TypeScript Version: 2.5.3
Code
function test(value) {
switch (value) {
case 1:
let foo = 10;
break;
case 2:
foo = 20; // Runtime ReferenceError: foo is not defined
break;
default:
}
}
test(2);
tsc --target es2015 (or higher)
Expected behavior:
This should probably produce a compile time error: Block-scoped variable 'pen' used before its declaration.
on reference to foo in case 2
.
Actual behavior:
The code type-checks and compiles fine, however, when running the es2015 transpiled output, you will receive a ReferenceError error at runtime. Ideally this type of error could be caught at compile time.