-
Notifications
You must be signed in to change notification settings - Fork 13.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 our terms of service and privacy 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 mode Co-authored-by: jakebailey <[email protected]>
… regular JSX elements Co-authored-by: jakebailey <[email protected]>
tests/baselines/reference/jsxJsxsCjsTransformCustomImportPragma(jsx=react-jsx).errors.txt
Show resolved
Hide resolved
… modes Co-authored-by: jakebailey <[email protected]>
|
@typescript-bot test it |
|
Hey @jakebailey, the results of running the DT tests are ready. Everything looks the same! |
|
@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! |
|
@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! |
|
@typescript-bot pack this |
|
Starting jobs; this comment will be updated as builds start and complete.
|
|
@typescript-bot pack this |
|
Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running |
|
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) |
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 more Copilot coding agent tips in the docs.