mirror of
https://github.com/swc-project/swc.git
synced 2024-12-27 15:42:51 +03:00
fix(es/compat): Fix destructuring of export class/function (#8371)
**Related issue:** - Closes #8366
This commit is contained in:
parent
c77f987b9b
commit
630f9d342f
21
crates/swc/tests/fixture/issues-8xxx/8366/input/.swcrc
Normal file
21
crates/swc/tests/fixture/issues-8xxx/8366/input/.swcrc
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"jsc": {
|
||||||
|
"parser": {
|
||||||
|
"syntax": "typescript",
|
||||||
|
"tsx": false
|
||||||
|
},
|
||||||
|
"loose": false,
|
||||||
|
"minify": {
|
||||||
|
"compress": false,
|
||||||
|
"mangle": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"module": {
|
||||||
|
"type": "es6"
|
||||||
|
},
|
||||||
|
"minify": false,
|
||||||
|
"isModule": true,
|
||||||
|
"env": {
|
||||||
|
"targets": "Chrome >= 50"
|
||||||
|
}
|
||||||
|
}
|
5
crates/swc/tests/fixture/issues-8xxx/8366/input/index.js
Normal file
5
crates/swc/tests/fixture/issues-8xxx/8366/input/index.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export class F {
|
||||||
|
a({ b, c } = undefined) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function f({ b, c } = undefined) { }
|
@ -0,0 +1,8 @@
|
|||||||
|
export class F {
|
||||||
|
a(ref) {
|
||||||
|
let _ref = ref === void 0 ? undefined : ref, b = _ref.b, c = _ref.c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export function f(ref) {
|
||||||
|
let _ref = ref === void 0 ? undefined : ref, b = _ref.b, c = _ref.c;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
use std::iter;
|
use std::{iter, mem};
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use swc_common::{util::take::Take, Spanned, SyntaxContext, DUMMY_SP};
|
use swc_common::{util::take::Take, Spanned, SyntaxContext, DUMMY_SP};
|
||||||
@ -559,6 +559,12 @@ impl VisitMut for AssignFolder {
|
|||||||
self.exporting = old;
|
self.exporting = old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_mut_function(&mut self, f: &mut Function) {
|
||||||
|
let exporting = mem::replace(&mut self.exporting, false);
|
||||||
|
f.visit_mut_children_with(self);
|
||||||
|
self.exporting = exporting;
|
||||||
|
}
|
||||||
|
|
||||||
fn visit_mut_expr(&mut self, expr: &mut Expr) {
|
fn visit_mut_expr(&mut self, expr: &mut Expr) {
|
||||||
let ignore_return_value = self.ignore_return_value.take().is_some();
|
let ignore_return_value = self.ignore_return_value.take().is_some();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user