Title: JSX Fragments are in-properly typed with `<>>` syntax, when using `react-jsx` JSX option · Issue #62358 · microsoft/TypeScript · GitHub
Open Graph Title: JSX Fragments are in-properly typed with `<>>` syntax, when using `react-jsx` JSX option · Issue #62358 · microsoft/TypeScript
X Title: JSX Fragments are in-properly typed with `<>>` syntax, when using `react-jsx` JSX option · Issue #62358 · microsoft/TypeScript
Description: 🔎 Search Terms JSX, Fragment, children type 🕗 Version & Regression Information Bug exists since TypeScript introduces "jsx": "react-jsx" from version 4.1.2 until next version (6.0.0-dev.20250830). ⏯ Playground Link https://stackblitz.com...
Open Graph Description: 🔎 Search Terms JSX, Fragment, children type 🕗 Version & Regression Information Bug exists since TypeScript introduces "jsx": "react-jsx" from version 4.1.2 until next version (6.0.0-dev.20250830). ...
X Description: 🔎 Search Terms JSX, Fragment, children type 🕗 Version & Regression Information Bug exists since TypeScript introduces "jsx": "react-jsx" from version 4.1.2 until next versio...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/62358
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSX Fragments are in-properly typed with `\u003c>\u003c/>` syntax, when using `react-jsx` JSX option","articleBody":"### 🔎 Search Terms\n\nJSX, Fragment, children type\n\n### 🕗 Version & Regression Information\n\nBug exists since TypeScript introduces `\"jsx\": \"react-jsx\"` from version 4.1.2 until `next` version (`6.0.0-dev.20250830`).\n\n### ⏯ Playground Link\n\nhttps://stackblitz.com/edit/stackblitz-starters-sffhmvvz?file=index.tsx\n\n### 💻 Code\n\n```tsx\nimport { Fragment } from \"@/jsx-runtime\";\n\n\u003cFragment>\n {\"ok\"}\n {({ foo }) => \"also ok\"}\n\u003c/Fragment>;\n\n\u003c>\n {\"ok\"}\n {({ foo }) => \"not ok\"}\n {/* ^ Binding element 'foo' implicitly has an 'any' type. */}\n\u003c/>;\n```\n\nWith following `@/jsx-runtime` definition:\n\n```ts\nexport const jsx = (...args: unknown[]) => {};\n\ntype JsxElement =\n | JsxElementArray\n | undefined\n | string\n | ((arg: { foo: \"bar \" }) => void);\ninterface JsxElementArray extends Array\u003cJsxElement> {}\n\ninterface FragmentProps {\n children?: JsxElement;\n}\n\nexport const Fragment = (props: FragmentProps) => {};\n```\n\nand tsconfig:\n\n```json\n{\n \"compilerOptions\": {\n \"strict\": true,\n \"jsx\": \"react-jsx\",\n \"jsxImportSource\": \"@\",\n // [...]\n }\n}\n```\n\n### 🙁 Actual behavior\n\nThe first JSX expression using `\u003cFragment>` pass the type checking while the second JSX using `\u003c>` syntax reports error due to it's children was typed to `any`:\n```\nindex.tsx:10:7 - error TS7031: Binding element 'foo' implicitly has an 'any' type.\n\n10 {({ foo }) => \"not ok\"}\n ~~~\n\n\nFound 1 error in index.tsx:10\n```\n\n### 🙂 Expected behavior\n\nThese two JSX expressions should both pass the type checking.\n\n### Additional information about the issue\n\nThis issue was first mentioned at #50429 and fixed in #59933, but the fix only take effects on `\"jsx\": \"react\"` not `\"jsx\": \"react-jsx\"`, while the latter is a more encouraged approach in a modern project.","author":{"url":"https://github.com/guyutongxue","@type":"Person","name":"guyutongxue"},"datePublished":"2025-08-30T08:31:53Z","url":"https://github.com/microsoft/TypeScript/issues/62358"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b83dc918-e808-569e-3083-c30484a7e1ac |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 911A:1087D4:FAAE39:14F0FA5:6B0112AC |
| html-safe-nonce | 528618efe241b0877b317a5603cdc2c5f864385a52345239671008e61f993dea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTFBOjEwODdENDpGQUFFMzk6MTRGMEZBNTo2QjAxMTJBQyIsInZpc2l0b3JfaWQiOiI1MTIxOTc2Nzg0MDgxOTgyMTI0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c15b7b460cae14a0cc61e4a9f450fe75bd763379a049fe54a2ab68cada6ad19f |
| hovercard-subject-tag | issue:3368913878 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/62358/issue_layout |
| twitter:image | https://opengraph.githubassets.com/abbd4848c55531ad00e69ddbcf4f6775af0aa3448dc183d4f826516105e99773/microsoft/TypeScript/issues/62358 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/abbd4848c55531ad00e69ddbcf4f6775af0aa3448dc183d4f826516105e99773/microsoft/TypeScript/issues/62358 |
| og:image:alt | 🔎 Search Terms JSX, Fragment, children type 🕗 Version & Regression Information Bug exists since TypeScript introduces "jsx": "react-jsx" from version 4.1.2 until next version (6.0.0-dev.20250830). ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | guyutongxue |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width