-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: do not use JSX.ElementChildrenAttribute
under jsx: react-jsx
or jsx: react-jsxdev
#60880
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be good to add a test case that defines ElementChildrenAttribute
as something different than children
to verify that it's ignored in favor of "hard-coded" children
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed! Added a test case.
…react-jsx and react-jsxdev
@typescript-bot test it |
@jakebailey Here are the results of running the user tests with tsc comparing Everything looks good! |
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
@jakebailey Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
Happy Holidays! Fixes #60572
🖼️ Background
Under
jsx: react-jsx
orjsx: react-jsxdev
, the name of the prop for JSX children is alwayschildren
. The jsx transformer properly implements this:TypeScript/src/compiler/transformers/jsx.ts
Line 308 in 56a0825
However, the type checker didin't take this into consideration. Instead, it used
JSX.ElementChildrenAttribute
to determine the name of prop. If type definition lacks this interface, undesirable compiler errors are emitted (like the one mentioned in the linked issue).It is of note that, I believe, no practical type definition for JSX libraries ever provided such definition that would lead to errors like those.
That said, I think the current behavior is still a bit harmful to those who want to learn how to write type definitions for JSX libraries, so proposing a fix.
🦾 Solution
This PR fixes the
getJsxElementChildrenPropertyName
function so thatchildren
is hard-coded under thesejsx
modes.🌵 Current Behavior
code:
Errors:
✨ New Behavior
(No error)