Title: Typing number of children in TSX · Issue #22759 · microsoft/TypeScript · GitHub
Open Graph Title: Typing number of children in TSX · Issue #22759 · microsoft/TypeScript
X Title: Typing number of children in TSX · Issue #22759 · microsoft/TypeScript
Description: Imagine a component which requires some exact number of children passed. Can it be currently expressed in TypeScript? Tuple doesn't work here. Code import React from 'react' interface ResizablePanelProps { children: [React.ReactNode, Rea...
Open Graph Description: Imagine a component which requires some exact number of children passed. Can it be currently expressed in TypeScript? Tuple doesn't work here. Code import React from 'react' interface ResizablePane...
X Description: Imagine a component which requires some exact number of children passed. Can it be currently expressed in TypeScript? Tuple doesn't work here. Code import React from 'react' interface R...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/22759
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Typing number of children in TSX","articleBody":"Imagine a component which requires some exact number of children passed.\r\n\r\nCan it be currently expressed in TypeScript? Tuple doesn't work here.\r\n\r\n**Code**\r\n\r\n```ts\r\nimport React from 'react'\r\n\r\ninterface ResizablePanelProps {\r\n children: [React.ReactNode, React.ReactNode]\r\n}\r\n\r\nclass ResizablePanel extends React.Component\u003c\r\n ResizablePanelProps, any> {}\r\n\r\nconst test = \u003cResizablePanel>\r\n \u003cdiv />\r\n \u003cdiv />\r\n\u003c/ResizablePanel>\r\n```\r\n\r\n**Expected behavior:**\r\nPass.\r\n\r\n**Actual behavior:**\r\n```\r\nType '{ children: Element[]; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes\u003cResizablePanel> & Readonly\u003c{ children?: ReactNode;...'.\r\n Type '{ children: Element[]; }' is not assignable to type 'Readonly\u003cResizablePanelProps>'.\r\n Types of property 'children' are incompatible.\r\n Type 'Element[]' is not assignable to type '[ReactNode, ReactNode]'.\r\n Property '0' is missing in type 'Element[]'.\r\n```\r\n\r\n\r\n**Code**\r\n\r\n```ts\r\nimport React from 'react'\r\n\r\ninterface ResizablePanelProps {\r\n children: [React.ReactNode, React.ReactNode]\r\n}\r\n\r\nclass ResizablePanel extends React.Component\u003c\r\n ResizablePanelProps, any> {}\r\n\r\nconst test = \u003cResizablePanel>\r\n \u003cdiv />\r\n \u003cdiv />\r\n \u003cdiv />\r\n\u003c/ResizablePanel>\r\n```\r\n\r\n**Expected behavior:**\r\nFail, provided 3 nodes instead of 2.\r\n\r\n**Playground Link:** \r\nhttps://stackblitz.com/edit/react-ts-8tttua\r\n","author":{"url":"https://github.com/methyl","@type":"Person","name":"methyl"},"datePublished":"2018-03-21T12:33:44Z","url":"https://github.com/microsoft/TypeScript/issues/22759"}
| 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:577f9e6c-26d9-bcdc-e5ea-8d9cd0a5c3cb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C2A:D405E:3C3B6C7:4F3FCF9:6B0451C0 |
| html-safe-nonce | f7940498ea7e356cb1125ab3133b80298650b9fa43858d31180852353610052c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzJBOkQ0MDVFOjNDM0I2Qzc6NEYzRkNGOTo2QjA0NTFDMCIsInZpc2l0b3JfaWQiOiI3MjE0NjQ1ODQ3NTQyNDg1NDQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 11addb119f13ec0671fdee5a23e8e049803033bd04e264f42662b724d8b83cc9 |
| hovercard-subject-tag | issue:307226188 |
| 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/22759/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6c3a4389c76fc7773a65107eae121c8648c04f149561b912aa6ae4810105dc87/microsoft/TypeScript/issues/22759 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6c3a4389c76fc7773a65107eae121c8648c04f149561b912aa6ae4810105dc87/microsoft/TypeScript/issues/22759 |
| og:image:alt | Imagine a component which requires some exact number of children passed. Can it be currently expressed in TypeScript? Tuple doesn't work here. Code import React from 'react' interface ResizablePane... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | methyl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 910ca0e260cfec6aff11407d8dc6a0d3a4cd381a2ec9ada56627b063426892a0 |
| 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 | e086f9b7e88322eb2b41885a6ad425b215737fa5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width