SolvedDefinitelyTyped React components with multiple root elements are not supported

React 16 components can have multiple root elements.

const Items = ({ items }: MyProps) => items.map(item => <div key={item.id}>{item.name}</div>)

However, TypeScript will break with:
error TS2605: JSX element type 'Element[]' is not a constructor function for JSX elements. Property 'render' is missing in type 'Element[]'.

17 Answers

✔️Accepted Answer

(#20356 (comment))
as a workaround without :any

function getSingleElement(): JSX.Element {
    return <>{itemsInArray}</>;
}

Other Answers:

I was able to resolve this by returning my map of items inside a fragment. It's not ideal, but it works.

The problem is still present for 16.0.25

Just leaving my reproduction repo of my SO question here for reference:
https://github.com/edorivai/ts-sfc-array

No. We'll probably need to wait for microsoft/TypeScript#21699 which is aimed to be included in TypeScript 2.8. There are several steps which need to be implemented first: microsoft/TypeScript#20239 (comment).

More Issues: