fix: ensure […map.keys] can be correctly transformed in loose mode (#11901)

This commit is contained in:
Huáng Jùnliàng 2020-07-31 15:26:22 -04:00 committed by GitHub
parent 08054181c3
commit c41dcd045b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -518,7 +518,7 @@ class BlockScoping {
// remap loop heads with colliding variables
if (this.loop) {
// nb: clone outsideRefs keys since the map is modified within the loop
for (const name of [...outsideRefs.keys()]) {
for (const name of Array.from(outsideRefs.keys())) {
const id = outsideRefs.get(name);
if (

View File

@ -210,6 +210,13 @@
}),
).not.toThrow();
});
it("#11897 - [...map.keys()] in Babel source should be transformed correctly", () => {
expect(() =>
Babel.transform("for (let el of []) { s => el }", {
plugins: ["transform-block-scoping"],
}),
).not.toThrow();
});
});
},
);