rpetrich / babel-plugin-transform-async-to-promises

Transform async/await to somewhat idiomatic JavaScript promise chains
MIT License
246 stars 17 forks source link

Undeclared variables being assigned when used with preset env targeting ES5 #45

Closed i-like-robots closed 5 years ago

i-like-robots commented 5 years ago

When using the babel-plugin-transform-async-to-promises along with @babel/preset-env targeting an ES5 environment (such as IE 11) variables can be assigned without first being declared which causes the following error/s:

ReferenceError: assignment to undeclared variable varname

I have created a minimum test case demonstrating this issue here: https://github.com/i-like-robots/broken-babel-async-await-transform-test-case

There appears to be several ways to mitigate the issue as manifested in the example above:

This may be a duplicate of #38

rpetrich commented 5 years ago

Babel's scope tracking got more strict in babel 7.6 and broke the tracking of variables across functions; this is now remedied in master and will be in the next release.

i-like-robots commented 5 years ago

Thank you @rpetrich 👍