-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already created
Description
π Search Terms
jsx children
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about jsx
β― Playground Link
Playground link with relevant code
π» Code
import React from 'react'
// This example comes from https://github.com/vercel/next.js/blob/5544adc481f8821567e947a6e6d51d9d68ebd367/packages/next/shared/lib/head.tsx#L172
declare function Head({ children }: {
children: React.ReactNode;
}): JSX.Element;
// This typechecks
const PageWithJSX = () => (
<Head>
<title>Hello</title>
</Head>
)
// This does not typecheck
const PageWithoutJSX = () => React.createElement(Head, {},
React.createElement('title', {}, 'Hello'),
)
π Actual behavior
The non-JSX code gives the type error:
No overload matches this call.
The last overload gave the following error.
Argument of type '{}' is not assignable to parameter of type 'Attributes & { children: ReactNode; }'.
Property 'children' is missing in type '{}' but required in type '{ children: ReactNode; }'.(2769)
input.tsx(5, 5): 'children' is declared here.
π Expected behavior
No type error should be given, because it's just the same as the code that does type-check, only without JSX.
antliann and jedwards1211
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already created