Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions crates/oxc_parser/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,15 +426,6 @@ pub fn return_statement_only_in_function_body(span: Span) -> OxcDiagnostic {
.with_label(span)
}

#[cold]
pub fn jsx_expressions_may_not_use_the_comma_operator(span: Span) -> OxcDiagnostic {
// OxcDiagnostic::error("TS18007: JSX expressions may not use the comma
// operator.")
ts_error("18007", "JSX expressions may not use the comma operator")
.with_help("Did you mean to write an array?")
.with_label(span)
}

#[cold]
pub fn invalid_identifier_in_using_declaration(span: Span) -> OxcDiagnostic {
OxcDiagnostic::error("Using declarations may not have binding patterns.").with_label(span)
Expand Down
7 changes: 1 addition & 6 deletions crates/oxc_parser/src/jsx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,7 @@ impl<'a> ParserImpl<'a> {

fn parse_jsx_assignment_expression(&mut self) -> Expression<'a> {
self.context(Context::default().and_await(self.ctx.has_await()), self.ctx, |p| {
let expr = p.parse_expr();
if let Expression::SequenceExpression(seq) = &expr {
let error = diagnostics::jsx_expressions_may_not_use_the_comma_operator(seq.span);
return p.fatal_error(error);
}
expr
p.parse_expr()
})
}

Expand Down
10 changes: 10 additions & 0 deletions crates/oxc_semantic/src/checker/typescript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,12 @@ fn invalid_jsx_attribute_value(span: Span) -> OxcDiagnostic {
.with_label(span)
}

fn jsx_expressions_may_not_use_the_comma_operator(span: Span) -> OxcDiagnostic {
ts_error("18007", "JSX expressions may not use the comma operator")
.with_help("Did you mean to write an array?")
.with_label(span)
}

pub fn check_jsx_expression_container(
container: &JSXExpressionContainer,
ctx: &SemanticBuilder<'_>,
Expand All @@ -554,4 +560,8 @@ pub fn check_jsx_expression_container(
{
ctx.error(invalid_jsx_attribute_value(container.span()));
}

if matches!(container.expression, JSXExpression::SequenceExpression(_)) {
ctx.error(jsx_expressions_may_not_use_the_comma_operator(container.expression.span()));
}
}
5 changes: 2 additions & 3 deletions tasks/coverage/snapshots/estree_typescript.snap
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
commit: 15392346

estree_typescript Summary:
AST Parsed : 6480/6481 (99.98%)
AST Parsed : 6481/6481 (100.00%)
Positive Passed: 6478/6481 (99.95%)
Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/jsx/jsxReactTestSuite.tsx
JSX expressions may not use the comma operator
Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/jsxReactTestSuite.tsx

Mismatch: tasks/coverage/typescript/tests/cases/conformance/jsx/tsxReactEmitEntities.tsx

Expand Down
Loading