Skip to content

Commit

Permalink
fix: disallow_ambiguous_jsx_like
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Jan 22, 2025
1 parent 5ad3bcb commit 973e63a
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions crates/swc_ecma_parser/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,10 @@ impl<I: Tokens> Parser<I> {
);
self.input.token_context_mut().pop();
}
} else if is!(self, '<') {
} else if is!(self, '<') && !self.input.syntax().disallow_ambiguous_jsx_like() {
let res = self.try_parse_ts(|p| {
let type_parameters = p.parse_ts_type_params(false, true)?;
let mut arrow = p.parse_assignment_expr_base()?;
match *arrow {
Expr::Arrow(ArrowExpr {
ref mut span,
ref mut type_params,
..
}) => {
*span = Span::new(type_parameters.span.lo, span.hi);
*type_params = Some(type_parameters);
}
_ => unexpected!(p, "("),
}
Ok(Some(arrow))
let expr = p.parse_assignment_expr_base()?;
Ok(Some(expr))
});
if let Some(res) = res {
return Ok(res);
Expand Down

0 comments on commit 973e63a

Please sign in to comment.