Title: JSX bug when combining union and intersection types · Issue #15355 · microsoft/TypeScript · GitHub
Open Graph Title: JSX bug when combining union and intersection types · Issue #15355 · microsoft/TypeScript
X Title: JSX bug when combining union and intersection types · Issue #15355 · microsoft/TypeScript
Description: TypeScript Versions: 2.2.2, and the 2.3.0 mistakenly released last week Code import * as React from 'react'; import { ComponentClass, StatelessComponent } from 'react'; export type ComponentType
= ComponentClass
| StatelessComponen...
Open Graph Description: TypeScript Versions: 2.2.2, and the 2.3.0 mistakenly released last week Code import * as React from 'react'; import { ComponentClass, StatelessComponent } from 'react'; export type ComponentType
...
X Description: TypeScript Versions: 2.2.2, and the 2.3.0 mistakenly released last week Code import * as React from 'react'; import { ComponentClass, StatelessComponent } from 'react'; export type ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/15355
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JSX bug when combining union and intersection types","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Versions:** 2.2.2, and the 2.3.0 mistakenly released last week\r\n\r\n**Code**\r\n\r\n```ts\r\nimport * as React from 'react';\r\nimport { ComponentClass, StatelessComponent } from 'react';\r\n\r\nexport type ComponentType\u003cP> = ComponentClass\u003cP> | StatelessComponent\u003cP>;\r\n\r\nexport function withProps\u003cP1, P2>(Component: ComponentType\u003cP1 & P2>, props1: P1) {\r\n return (props2: P2) => \u003cComponent {...props1} {...props2} />;\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nSuccessful compilation.\r\n\r\n**Actual behavior:**\r\n\r\n`TS2324: Property 'children' is missing in type '(IntrinsicAttributes & IntrinsicClassAttributes\u003cComponent\u003cP1 & P2, ComponentState>> & Readonly\u003c{ ...'.`\r\n\r\nSeems to me that this should be possible, since separate functions for each half of the union type pass the typechecker successfully:\r\n\r\n```ts\r\nfunction withProps2\u003cP1, P2>(Component: StatelessComponent\u003cP1 & P2>, props1: P1) {\r\n return (props2: P2) => \u003cComponent {...props1} {...props2} />;\r\n}\r\n\r\nfunction withProps3\u003cP1, P2>(Component: ComponentClass\u003cP1 & P2>, props1: P1) {\r\n return (props2: P2) => \u003cComponent {...props1} {...props2} />;\r\n}\r\n```","author":{"url":"https://github.com/whatisaphone","@type":"Person","name":"whatisaphone"},"datePublished":"2017-04-24T20:45:51Z","url":"https://github.com/microsoft/TypeScript/issues/15355"}
| 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:233d0acc-b171-3a46-a342-20425e2307c0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E350:3DD488:2FF7B39:3CF9AD6:6B01CAA6 |
| html-safe-nonce | d11c646358af7dc2097963b4c3309cb35c2e37197aacd7d6e253386ae58aeb99 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzUwOjNERDQ4ODoyRkY3QjM5OjNDRjlBRDY6NkIwMUNBQTYiLCJ2aXNpdG9yX2lkIjoiNTM2NDAyMjcwMjU4OTk4NzQ5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c1c73b671e9de22bc6c42b914311775e57e8bb357864380faa750ed93f799557 |
| hovercard-subject-tag | issue:223945816 |
| 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/15355/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8ebe9ccd1cb2e92878842427fbb5ac349dd4548c58e61f1b04da5e93762ea315/microsoft/TypeScript/issues/15355 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8ebe9ccd1cb2e92878842427fbb5ac349dd4548c58e61f1b04da5e93762ea315/microsoft/TypeScript/issues/15355 |
| og:image:alt | TypeScript Versions: 2.2.2, and the 2.3.0 mistakenly released last week Code import * as React from 'react'; import { ComponentClass, StatelessComponent } from 'react'; export type ComponentType ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | whatisaphone |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width