Skip to content

redefine variable when converting let to var #477

@guoerwei

Description

@guoerwei
{
  let count = 0;
  setInterval(() => {
    console.log('first tick: ', ++count);
  }, 200);
}
{
  let count = 0;
  setInterval(() => {
    console.log('second tick: ', ++count);
  }, 300);
}

with babili, will simply converts to

{
  var a = 0;
  setInterval(function() {
    console.log('first tick: ', ++a)
  }, 200)
}
{
  var a = 0;
  setInterval(function() {
    console.log('second tick: ', ++a)
  }, 300)
}

and getting variable redefined

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bugwith es2015The bug is caused when used with es2015-block-scoping plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions