functiontest(v){switch(v){case1: {console.log('case 1');constdata=5;// if statement seems to be requiredif(data===123){constok=[].some(function(){return!!data;});// return seems to be requiredif(!ok)return2;}break;}case2: {console.log('case 2');break;}}}test(1);
The resulting code is:
functiontest(v){switch(v){case1:
{var_ret=function(){console.log('case 1');vardata=5;// if statement seems to be requiredif(data===123){varok=[].some(function(){return!!data;});// return seems to be requiredif(!ok)return{v: 2};}return"break";}();switch(_ret){case"break":
break;default:
if((typeof_ret==="undefined" ? "undefined" : (0,_typeof3.default)(_ret))==="object")return_ret.v;}}case2:
{console.log('case 2');break;}}}
Which clearly shows why the case is falling through to the next one.
This is very likely just a Babel issue, but the problem can be solved by including the es2015 preset (just adding "es2015" to the presets array in the .babelrc file in the reproduction - it's already installed) so I assume there's just something different between the presets es2015 and preset-babel-meteor which seems like it can be fixed on the meteor side.
As a note this appears to work fine in 1.5 beta 8.
Required console output for reproducing issue from reproduction:
This should be fixed if you run meteor update --release 1.4.3.3-beta.4 in your application directory. Please feel free to reopen this issue if it's not resolved for you.
When transpiling the following code the result no longer
break
s correctly in the1
case which then causes the2
case to also run.Reproduction: https://github.com/niftykins/meteor-switch-bug (created via a
meteor create
and then removing some unimportant files/packages)The resulting code is:
Which clearly shows why the case is falling through to the next one.
This is very likely just a Babel issue, but the problem can be solved by including the
es2015
preset (just adding"es2015"
to thepresets
array in the.babelrc
file in the reproduction - it's already installed) so I assume there's just something different between the presetses2015
andpreset-babel-meteor
which seems like it can be fixed on the meteor side.As a note this appears to work fine in
1.5 beta 8
.Required console output for reproducing issue from reproduction:
The text was updated successfully, but these errors were encountered: