From 47ba874f4fd5007d0e862274e6586faf6e65187e Mon Sep 17 00:00:00 2001 From: Dunqing Date: Sun, 12 Nov 2023 19:17:09 +0800 Subject: [PATCH] refactor(transformer/react-jsx): improve SpreadChildrenAreNotSupported error implementation (#1235) --- crates/oxc_transformer/src/react_jsx/mod.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/oxc_transformer/src/react_jsx/mod.rs b/crates/oxc_transformer/src/react_jsx/mod.rs index 382a446ae..f958dd117 100644 --- a/crates/oxc_transformer/src/react_jsx/mod.rs +++ b/crates/oxc_transformer/src/react_jsx/mod.rs @@ -375,12 +375,6 @@ impl<'a> ReactJsx<'a> { let children = e.children(); - if children.len() == 1 { - if let Some(JSXChild::Spread(s)) = children.get(0) { - self.ctx.error(SpreadChildrenAreNotSupported(s.span)); - } - } - // Append children to object properties in automatic mode if is_automatic { let allocator = self.ast.allocator; @@ -656,8 +650,8 @@ impl<'a> ReactJsx<'a> { }, JSXChild::Element(e) => Some(self.transform_jsx(&JSXElementOrFragment::Element(e))), JSXChild::Fragment(e) => Some(self.transform_jsx(&JSXElementOrFragment::Fragment(e))), - JSXChild::Spread(_) => { - // Babel: Spread children are not supported in React. + JSXChild::Spread(e) => { + self.ctx.error(SpreadChildrenAreNotSupported(e.span)); None } }