Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bug with let/var and for loop when transpile to ES2015 code #696

Closed
paul-phan opened this issue Sep 24, 2017 · 1 comment
Closed

Bug with let/var and for loop when transpile to ES2015 code #696

paul-phan opened this issue Sep 24, 2017 · 1 comment
Labels
bug Confirmed bug duplicate with es2015 The bug is caused when used with es2015-block-scoping plugin

Comments

@paul-phan
Copy link

paul-phan commented Sep 24, 2017

Input Code

let abc = '123'
for (let i = 0; i < [1,2,3].length; i++) {
	abc = abc + '345'	
}

console.log(abc)

Actual Output

'use strict';for(var i=0;i<[1,2,3].length;i++){}console.log(abc);

Expected Output

for(var abc="123",i=0;i<[1,2,3].length;i++)abc+="345";console.log(abc);

Details

When I declare a let/var or even const variable before a for loop, It disappeared and make this variable undefined. You can test it with Babel Repl

@boopathi boopathi added bug Confirmed bug with es2015 The bug is caused when used with es2015-block-scoping plugin labels Sep 25, 2017
@boopathi
Copy link
Member

Closing this as duplicate of #485

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Confirmed bug duplicate with es2015 The bug is caused when used with es2015-block-scoping plugin
Projects
None yet
Development

No branches or pull requests

2 participants