Discovered a bug in my code and was surprised TS didn't catch it for me. It doesn't seem like this is allowed (in Chrome 60, at least).
TypeScript Version: 2.2.4
Code
var baz: number = 2
switch (baz) {
case 1:
let foo = 'bar'
break;
case 2:
document.write(foo)
break;
}
Playground: link
Expected behavior:
TS should warn/error in second case statement that foo is not declared.
Actual behavior:
TS does not throw an error and foo is undefined
If this is expected/by design, I'm interested to know why (and if there's a way to catch it).
Discovered a bug in my code and was surprised TS didn't catch it for me. It doesn't seem like this is allowed (in Chrome 60, at least).
TypeScript Version: 2.2.4
Code
Playground: link
Expected behavior:
TS should warn/error in second case statement that
foois not declared.Actual behavior:
TS does not throw an error and
foois undefinedIf this is expected/by design, I'm interested to know why (and if there's a way to catch it).