- Notifications
You must be signed in to change notification settings - Fork13.1k
Fix JSX fragment children type checking in react-jsx mode#62743
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
…x modeCo-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
… regular JSX elementsCo-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txtShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
… modesCo-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
jakebailey commentedNov 11, 2025
@typescript-bot test it |
typescript-bot commentedNov 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
typescript-bot commentedNov 11, 2025
Hey@jakebailey, the results of running the DT tests are ready. Everything looks the same! |
typescript-bot commentedNov 11, 2025
@jakebailey Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
typescript-bot commentedNov 11, 2025
@jakebailey Here they are:tscComparison Report - baseline..pr
System info unknown Hosts
Scenarios
Developer Information: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
typescript-bot commentedNov 11, 2025
@jakebailey Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
jakebailey commentedNov 11, 2025
@typescript-bot pack this |
typescript-bot commentedNov 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Starting jobs; this comment will be updated as builds start and complete.
|
jakebailey commentedNov 11, 2025
@typescript-bot pack this |
typescript-bot commentedNov 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
typescript-bot commentedNov 11, 2025
Hey@jakebailey, I've packed this intoan installable tgz. You can install it for testing by referencing it in your and then running |
ArnaudBarre commentedNov 11, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I just tested the build and I now get an error if an object is passed as a child of a shorthand fragment when using Running on 560 tsx files, it caught the same two cases than my custom linter rule (opaque type which is a number at runtime) |
jakebailey commentedNov 14, 2025
I asked@weswigham and he said this PR is wrong, unfortunately. |
Uh oh!
There was an error while loading.Please reload this page.
Fixes#62358
JSX fragments (
<>...</>) inreact-jsx/react-jsxdevmodes were not type-checking children, while explicit<Fragment>worked correctly:Changes
Extended fragment factory resolution to modern JSX modes
getJSXFragmentType: AddedJsxEmit.ReactJSXandJsxEmit.ReactJSXDevtoshouldResolveFactoryReferencecheckJsxEmit.Reactwas checked, causing fragments to returnanyTypein modern modesAdded contextual typing for fragment children
createJsxAttributesTypeFromAttributesProperty: Extract Fragment props type from factory signature and derive children contextual typecheckJsxChildren: Accept optional contextual type parameter, apply to fragment child expressions viacheckExpressionForMutableLocationWithContextualTypeFixed error message for modern JSX modes
getJSXFragmentType: When usingreact-jsx/react-jsxdevmodes, error messages now correctly reference "Fragment" instead of "React"@jsxImportSource preact)Test Coverage
Added
jsxFragmentChildrenCheck.tsxvalidating both syntaxes produce identical type checking.Updated baselines for existing tests now correctly report error 2879 when Fragment factory is missing in react-jsx modes (previously unreported due to
anyTypeearly return), with accurate error messages showing "Fragment" as the expected factory name.Original prompt
<></>syntax, when usingreact-jsxJSX option #62358💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.