Issue 1:
Choose one: is this a bug report or feature request?

Seems like a bug, since it's throwing validation errors from internal code on valid(ish) input, but given #3575 my preferred behavior would probably be a feature request.

Input Code

// test.js
import React from "react";
import ReactDOM from "react-dom";

const content = ['Hello ', <b>cruel</b>, ' world'];
const target = <div>{...content}</div>;
ReactDOM.render(target, document.body);

Babel/Babylon Configuration (.babelrc, package.json, cli command)

// .babelrc.js
module.exports = {
presets: ["@babel/react"]
}

// package.json
{
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.35",
"@babel/cli": "7.0.0-beta.35",
"@babel/preset-react": "7.0.0-beta.35",
"@types/react": "^16.0.31",
"@types/react-dom": "^16.0.3"
}
}

$ babel test.js

Expected Behavior

I'd prefer output something like:

const content = ['Hello ', React.createElement('b', null, 'cruel'), ' world'];
const target = React.createElement('div', null, ...content);
ReactDOM.render(target, document.body);

but tsc --jsx react emits without the ..., i.e. React.createElement('div', null, content).

More likely, given the discussion in #3575, simply giving a user-facing error message would be preferred? Something like transform-react-jsx does not support '{...children}', use '{children}'?

Current Behavior

C:\code\personal\babel-tsx-parsing>yarn babel src\index.js
yarn run v1.3.2
$ C:\code\personal\babel-tsx-parsing\node_modules\.bin\babel src\index.js
TypeError: Property arguments[2] of CallExpression expected node to be of a type ["Expression","SpreadElement","JSXNamespacedName"] but instead got "JSXSpreadChild"
at validate (C:\code\personal\babel-tsx-parsing\node_modules\@babel\types\lib\definitions\utils.js:88:13)
at validator (C:\code\personal\babel-tsx-parsing\node_modules\@babel\types\lib\definitions\utils.js:47:7)
at Object.validate (C:\code\personal\babel-tsx-parsing\node_modules\@babel\types\lib\definitions\utils.js:143:10)
at validate (C:\code\personal\babel-tsx-parsing\node_modules\@babel\types\lib\validators\validate.js:15:9)
at builder (C:\code\personal\babel-tsx-parsing\node_modules\@babel\types\lib\builders\builder.js:40:27)
at Object.CallExpression (C:\code\personal\babel-tsx-parsing\node_modules\@babel\types\lib\builders\generated\index.js:276:27)
at buildElementCall (C:\code\personal\babel-tsx-parsing\node_modules\@babel\helper-builder-react-jsx\lib\index.js:131:28)
at PluginPass.exit (C:\code\personal\babel-tsx-parsing\node_modules\@babel\helper-builder-react-jsx\lib\index.js:25:22)
at newFn (C:\code\personal\babel-tsx-parsing\node_modules\@babel\traverse\lib\visitors.js:223:21)
at NodePath._call (C:\code\personal\babel-tsx-parsing\node_modules\@babel\traverse\lib\path\context.js:64:19)

Context

React seems to distinguish between dynamic array contents (e.g. {arrayProp.map(toChild)}) and direct children only in that the latter do not warn on key, so the simple workaround is remove the ... and add keys, or to convert rendering a component.

I ran into this while converting some document.createElement() calls that walk a JSON description, so I was trying to avoid changing structure too much, and I don't have meaningful keys in the source yet.

Your Environment

software
version(s)

Babel
7.0.0-beta.32 ... .35

node
v6.11.4

npm
yarn 1.3.2

Operating System
Windows 10

Issue 2:
💻

Would you like to work on a fix?

How are you using Babel?

@rollup/plugin-babel

Input code

REPL

declare class A {}

function A () {}

Configuration file name

.babelrc

Configuration

{
"presets": ["@babel/preset-typescript"]
}

Current and expected behavior

I expect this construction to be compiled correctly because tsc can do it. However, currently Babel throws an error:

Duplicate declaration "A"
1 | declare class A {}
2 |
> 3 | function A () {}
|

Environment

Babel version(s): 7.15.5

Node: 16

npm: 7

OS: Windows 10

Monorepo: no

Possible solution

No response

Additional context

No response