fix(parser): await in jsx expression

closes #1740
This commit is contained in:
Boshen 2023-12-19 20:21:02 +08:00
parent 3b1212e8bd
commit 2b4d1bf142
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1
4 changed files with 14 additions and 5 deletions

View file

@ -250,7 +250,7 @@ impl<'a> Parser<'a> {
fn parse_jsx_assignment_expression(&mut self) -> Result<Expression<'a>> { fn parse_jsx_assignment_expression(&mut self) -> Result<Expression<'a>> {
let ctx = self.ctx; let ctx = self.ctx;
self.ctx = Context::default(); self.ctx = Context::default().and_await(ctx.has_await());
let expr = self.parse_expression(); let expr = self.parse_expression();
if let Ok(Expression::SequenceExpression(seq)) = &expr { if let Ok(Expression::SequenceExpression(seq)) = &expr {
return Err(diagnostics::JSXExpressionsMayNotUseTheCommaOperator(seq.span).into()); return Err(diagnostics::JSXExpressionsMayNotUseTheCommaOperator(seq.span).into());

View file

@ -1,3 +1,3 @@
codegen_misc Summary: codegen_misc Summary:
AST Parsed : 8/8 (100.00%) AST Parsed : 9/9 (100.00%)
Positive Passed: 8/8 (100.00%) Positive Passed: 9/9 (100.00%)

View file

@ -0,0 +1,9 @@
export const foo = () => ({
render: async () => {
ReactDOM.render(
<Bar {...config} attribute={await baz} />,
domNode,
() => {}
);
},
});

View file

@ -1,6 +1,6 @@
parser_misc Summary: parser_misc Summary:
AST Parsed : 8/8 (100.00%) AST Parsed : 9/9 (100.00%)
Positive Passed: 8/8 (100.00%) Positive Passed: 9/9 (100.00%)
Negative Passed: 3/3 (100.00%) Negative Passed: 3/3 (100.00%)
× Unexpected token × Unexpected token
╭─[fail/oxc-169.js:1:1] ╭─[fail/oxc-169.js:1:1]