Closed
Description
🐞 Bug report
at runtime, with and without AOT enabled
Is this a regression?
Yes, before auto-update target to es2015 it was valid es5 code. I think because in es5 when creating new variable without using (var,let,const), the variable is automatically global :
🔬 Minimal Reproduction
Anywhere in your angular app with target:es2015 write:
let t = 'b';
switch (t) {
case 'a':
let numberMin = 1;
console.log(numberMin)
break;
case 'b':
numberMin = 2;
console.log(numberMin)
break;
}
🔥 Exception or Error
ERROR ReferenceError: numberMin is not defined
🌍 Your Environment
Angular CLI: 8.0.0-beta.16
Node: 10.10.0
OS: win32 x64
Angular: 8.0.0-beta.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.800.0-beta.16
@angular-devkit/build-angular 0.800.0-beta.16
@angular-devkit/build-optimizer 0.800.0-beta.16
@angular-devkit/build-webpack 0.800.0-beta.16
@angular-devkit/core 8.0.0-beta.16
@angular-devkit/schematics 8.0.0-beta.16
@angular/cli 8.0.0-beta.16
@ngtools/webpack 8.0.0-beta.16
@schematics/angular 8.0.0-beta.16
@schematics/update 0.800.0-beta.16
rxjs 6.4.0
typescript 3.4.4
webpack 4.30.0
Anything else relevant?
cc @filipesilva
This kind of code is easy to fix to be es2015 valid. But due to the fact it happens only "at runtime" it is dificult on existing angular project to see where&when it happens.