Title: Intersection Types that have overlapping properties can fail · Issue #49264 · microsoft/TypeScript · GitHub
Open Graph Title: Intersection Types that have overlapping properties can fail · Issue #49264 · microsoft/TypeScript
X Title: Intersection Types that have overlapping properties can fail · Issue #49264 · microsoft/TypeScript
Description: This seems to be the source: #31838 Example: Try an intersection of 2 types where the same property has inconsistent overlapping types: type Bar = { Prop: string }; type Works = Bar & {Prop: number}; // Bar & {Prop: number} type ThisIsNe...
Open Graph Description: This seems to be the source: #31838 Example: Try an intersection of 2 types where the same property has inconsistent overlapping types: type Bar = { Prop: string }; type Works = Bar & {Prop: number...
X Description: This seems to be the source: #31838 Example: Try an intersection of 2 types where the same property has inconsistent overlapping types: type Bar = { Prop: string }; type Works = Bar & {Prop: nu...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/49264
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Intersection Types that have overlapping properties can fail","articleBody":"This seems to be the source: https://github.com/microsoft/TypeScript/pull/31838\r\n\r\nExample:\r\nTry an intersection of 2 types where the same property has inconsistent overlapping types:\r\n\r\n```\r\ntype Bar = {\r\n Prop: string\r\n};\r\n\r\ntype Works = Bar & {Prop: number}; // Bar & {Prop: number}\r\ntype ThisIsNever = Bar & {Prop: null}; // never\r\n```\r\n\r\nIt makes sense to me that individual types can be reduced to never, but why can intersecting types with nested overlapping property types get reduced to `never`?\r\n\r\nPlayground link: https://www.typescriptlang.org/play?ts=4.7.0-beta#code/C4TwDgpgBAQghgJygXigbwFBW1ACggezAC4oBnYBASwDsBzDAXwG4MMB6dqAdQIQGsyUAGa0IGUJCgBJGsAgIyEAMbAqBGiliIoAMnT4ipGgFcAtgCMFLKJ21J9aQySinL1ieGgA5CADcFWXlFFTUNLXgHA0IXGn9rZlsuSL1oo1d4hEY2O28CYCgIAA9IVQgAE08pbxMAG1qghSVVdU1UFMdnYzramzsAJRUIKgDy40ykqABREtCK0gADDrTYnsYFqAAKPiglnU6Y8YCshYBKKugAVRpyiFE48saQlvD2-ZXSExu7sXK+rkGymGoyOCkmM1K8jGu2WTkOUC+t3uFXWWx2eyicPScWO63OQA\r\n\r\nThis might be expected, but it does feel like a bug to me. My initial use case was joining a few different types together to get a union of all their keys. But since some props had a `null | undefined` type, it was reduced to `never`. Causing my use of those keys to fail unexpectedly. I would expect `ThisIsNever` to have a `Prop: never` property instead, or maybe a union of `string | null`. Or at-least surface an error saying the union is not possible because of `Prop` being incompatible.\r\n\r\nTested on: 4.6.4, 4.7.0-beta\r\nThis worked as expected in: v3.8.3. And starts not being expected in v3.9.7","author":{"url":"https://github.com/wdamien","@type":"Person","name":"wdamien"},"datePublished":"2022-05-26T18:23:57Z","url":"https://github.com/microsoft/TypeScript/issues/49264"}
| 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:3630aeb3-8c65-1fb5-c6a6-836c4cef4cce |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8836:1612C1:A72DDF:E380F6:6B04832C |
| html-safe-nonce | 42cf7cd89c2a92a66e7bc030a054164b8ec3a7e90e3d4e6cf7a82765b0d77550 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODM2OjE2MTJDMTpBNzJEREY6RTM4MEY2OjZCMDQ4MzJDIiwidmlzaXRvcl9pZCI6Ijc4NzQ5NzI4MDcwMzIyNDI5ODgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1621e6e4abe85ab6c00a21b8cd6bfa7cecd7db077074c65cf090a3d8d3370c8c |
| hovercard-subject-tag | issue:1249901212 |
| 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/49264/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1f3e837b4a736da266706339824b176da71f6e8e3f155c996a6fb17983ba33ae/microsoft/TypeScript/issues/49264 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1f3e837b4a736da266706339824b176da71f6e8e3f155c996a6fb17983ba33ae/microsoft/TypeScript/issues/49264 |
| og:image:alt | This seems to be the source: #31838 Example: Try an intersection of 2 types where the same property has inconsistent overlapping types: type Bar = { Prop: string }; type Works = Bar & {Prop: number... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wdamien |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1d5c152376e38b7d2e37f3d5179be29a73bee93b85110da28a4eebe1159cdc70 |
| 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 | f5017e8ff4ea25a8011fcf0f2a0e430c60dc86c8 |
| 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