mirror of
https://github.com/swc-project/swc.git
synced 2024-10-04 12:18:08 +03:00
fix(es/utils): Keep arguments to super
call (#3570)
This commit is contained in:
parent
7351ec2477
commit
f67796a962
@ -1907,6 +1907,34 @@ class A {
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
syntax(),
|
||||
|_| parameters(Default::default()),
|
||||
issue_3569,
|
||||
"
|
||||
export class TableView extends React.Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.getSearchForm = (innerWidth = 0)=>{
|
||||
this.getProps();
|
||||
};
|
||||
}
|
||||
}
|
||||
",
|
||||
"
|
||||
export class TableView extends React.Component {
|
||||
constructor(props){
|
||||
var _this;
|
||||
super(props), _this = this;
|
||||
this.getSearchForm = function () {
|
||||
let innerWidth = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
||||
_this.getProps();
|
||||
};
|
||||
}
|
||||
}
|
||||
"
|
||||
);
|
||||
|
||||
test!(
|
||||
syntax(),
|
||||
|_| tr(Config {
|
||||
|
@ -556,23 +556,20 @@ impl<'a> VisitMut for InitThis<'a> {
|
||||
fn visit_mut_expr(&mut self, expr: &mut Expr) {
|
||||
expr.visit_mut_children_with(self);
|
||||
|
||||
if let Expr::Call(CallExpr {
|
||||
callee: Callee::Super(Super { span: super_span }),
|
||||
span,
|
||||
..
|
||||
}) = expr
|
||||
if let Expr::Call(
|
||||
call_expr @ CallExpr {
|
||||
callee: Callee::Super(..),
|
||||
..
|
||||
},
|
||||
) = expr
|
||||
{
|
||||
let span = call_expr.span;
|
||||
*expr = Expr::Paren(ParenExpr {
|
||||
span: *span,
|
||||
span,
|
||||
expr: Box::new(Expr::Seq(SeqExpr {
|
||||
span: *span,
|
||||
span,
|
||||
exprs: vec![
|
||||
Box::new(Expr::Call(CallExpr {
|
||||
span: *span,
|
||||
callee: Callee::Super(Super { span: *super_span }),
|
||||
args: Vec::new(),
|
||||
type_args: None,
|
||||
})),
|
||||
Box::new(Expr::Call(call_expr.take())),
|
||||
Box::new(Expr::Assign(AssignExpr {
|
||||
span: DUMMY_SP,
|
||||
left: PatOrExpr::Pat(self.this_id.clone().into()),
|
||||
|
Loading…
Reference in New Issue
Block a user