mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
fix(es/compat): Visit AssignExpr right branch in FnEnvHoister (#8633)
**Related issue:** - Closes #8632
This commit is contained in:
parent
52b6fd8808
commit
e5d6de0ea9
19
crates/swc/tests/fixture/issues-8xxx/8632/input/.swcrc
Normal file
19
crates/swc/tests/fixture/issues-8xxx/8632/input/.swcrc
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": false
|
||||
},
|
||||
"target": "es2015",
|
||||
"loose": false,
|
||||
"minify": {
|
||||
"compress": false,
|
||||
"mangle": false
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
},
|
||||
"minify": false,
|
||||
"isModule": true
|
||||
}
|
22
crates/swc/tests/fixture/issues-8xxx/8632/input/index.ts
Normal file
22
crates/swc/tests/fixture/issues-8xxx/8632/input/index.ts
Normal file
@ -0,0 +1,22 @@
|
||||
export class Test {
|
||||
public async bad(): Promise<void> {
|
||||
let foo = false;
|
||||
|
||||
[foo] = await Promise.all(
|
||||
[
|
||||
this.foo(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public async good(): Promise<void> {
|
||||
let [foo] = await Promise.all(
|
||||
[
|
||||
this.foo(),
|
||||
]);
|
||||
}
|
||||
|
||||
private async foo(): Promise<boolean> {
|
||||
return true;
|
||||
}
|
||||
}
|
35
crates/swc/tests/fixture/issues-8xxx/8632/output/index.ts
Normal file
35
crates/swc/tests/fixture/issues-8xxx/8632/output/index.ts
Normal file
@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "Test", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return Test;
|
||||
}
|
||||
});
|
||||
const _async_to_generator = require("@swc/helpers/_/_async_to_generator");
|
||||
class Test {
|
||||
bad() {
|
||||
var _this = this;
|
||||
return _async_to_generator._(function*() {
|
||||
let foo = false;
|
||||
[foo] = yield Promise.all([
|
||||
_this.foo()
|
||||
]);
|
||||
})();
|
||||
}
|
||||
good() {
|
||||
var _this = this;
|
||||
return _async_to_generator._(function*() {
|
||||
let [foo] = yield Promise.all([
|
||||
_this.foo()
|
||||
]);
|
||||
})();
|
||||
}
|
||||
foo() {
|
||||
return _async_to_generator._(function*() {
|
||||
return true;
|
||||
})();
|
||||
}
|
||||
}
|
@ -386,7 +386,7 @@ impl VisitMut for FnEnvHoister {
|
||||
}) => {
|
||||
let expr = match left {
|
||||
AssignTarget::Simple(e) => e,
|
||||
AssignTarget::Pat(e) => {
|
||||
AssignTarget::Pat(..) => {
|
||||
e.visit_mut_children_with(self);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user