Always use the native (or polyfilled) Promise in transform-async-to-generator (#5536)
* Always use the native (or polyfilled) Promise in transform-async-to-generator Fixes #5531 * Simplify scope handling to only un-shadow the Program's Promise Only the helper needs to see the native Promise.
This commit is contained in:
@@ -9,6 +9,13 @@ export default function () {
|
||||
Function(path, state) {
|
||||
if (!path.node.async || path.node.generator) return;
|
||||
|
||||
// Ensure any Promise bindings at the Program level are renamed
|
||||
// so the asyncToGenerator helper only sees the native Promise
|
||||
const programScope = path.scope.getProgramParent();
|
||||
if (programScope.hasBinding("Promise", true)) {
|
||||
programScope.rename("Promise");
|
||||
}
|
||||
|
||||
remapAsyncToGenerator(path, state.file, {
|
||||
wrapAsync: state.addHelper("asyncToGenerator"),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user