Title: Unexpected intersection type constraint error related to union, generic type and private field · Issue #38236 · microsoft/TypeScript · GitHub
Open Graph Title: Unexpected intersection type constraint error related to union, generic type and private field · Issue #38236 · microsoft/TypeScript
X Title: Unexpected intersection type constraint error related to union, generic type and private field · Issue #38236 · microsoft/TypeScript
Description: TypeScript Version: 3.9.1-rc/4.0.0-dev.20200428 3.9.0-beta seems to be fine. Search Terms: intersection,private,generic,constraint,union Code type Type = {foo: string} | {bar: number}; class SyncableObject { private foo: unknown; } inter...
Open Graph Description: TypeScript Version: 3.9.1-rc/4.0.0-dev.20200428 3.9.0-beta seems to be fine. Search Terms: intersection,private,generic,constraint,union Code type Type = {foo: string} | {bar: number}; class Syncab...
X Description: TypeScript Version: 3.9.1-rc/4.0.0-dev.20200428 3.9.0-beta seems to be fine. Search Terms: intersection,private,generic,constraint,union Code type Type = {foo: string} | {bar: number}; class Syncab...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38236
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpected intersection type constraint error related to union, generic type and private field","articleBody":"**TypeScript Version:** 3.9.1-rc/4.0.0-dev.20200428\r\n\r\n3.9.0-beta seems to be fine.\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:** intersection,private,generic,constraint,union\r\n\r\n**Code**\r\n\r\n```ts\r\ntype Type = {foo: string} | {bar: number};\r\n\r\nclass SyncableObject {\r\n private foo: unknown;\r\n}\r\n\r\ninterface SyncableRef\u003cT extends ISyncableObject> {\r\n}\r\n\r\ninterface ISyncableObject\u003cT = object> extends SyncableObject {\r\n}\r\n\r\ntype __ValueDescriptorType\u003c\r\n T extends Type | undefined\r\n> = T extends ISyncableObject\r\n ? SyncableRef\u003cT>\r\n : T;\r\n```\r\n\r\n**Expected behavior:** No error\r\n\r\n**Actual behavior:**\r\n\r\n```\r\nType 'ISyncableObject\u003cobject> & T' does not satisfy the constraint 'ISyncableObject\u003cobject>'.\r\n Property 'foo' is missing in type 'ISyncableObject\u003cobject> & T' but required in type 'ISyncableObject\u003cobject>'.(2344)\r\n```\r\n\r\n**Playground Link:** [Playground](https://www.typescriptlang.org/play/index.html?ts=4.0.0-dev.20200429&ssl=1&ssc=1&pln=18&pc=1#code/C4TwDgpgBAKu0F4oG8BmB7dAuKBnYATgJYB2A5gL5QA+KARgIYE4kCuAtnRARQNwBQ-AMYAbBrlxQAyiBJCGdERADydAFYQhwFPyhQwxAG4Ng0DNiisSAaxLoA7iQEVBpUwVQMh0GXIVKAJQhUAB4YKAgAD1MSABNJAElfeUUVdU1gAD4dF343bk9vKCTZFKVVDS0wqCR0dK1sqJj46VL-NMrtZH5c0EgoAH0BgDUGEVYIABEIXCFiMGB0AjhIEN1YCOiIOMkV6ForWODSCFj+bKRwpu2Wkr9Uioz1gH5W+8DgsMz1nBgBIA)\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/vilicvane","@type":"Person","name":"vilicvane"},"datePublished":"2020-04-29T04:41:52Z","url":"https://github.com/microsoft/TypeScript/issues/38236"}
| 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:777206a9-6319-5c55-1439-ddacc8f84d8e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9294:BBAAA:D562E8:11A8DAE:6B00F8E3 |
| html-safe-nonce | 246b69cb172bf72a9e4a7cde4184f23190e5cba4b7f0cd19ff784bd4f30da4c7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Mjk0OkJCQUFBOkQ1NjJFODoxMUE4REFFOjZCMDBGOEUzIiwidmlzaXRvcl9pZCI6Ijg3ODg0NjgwMzU0MTg2NTA4NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0087e7550797918ce1266d3bc2bc8d42c0aa2356564b1a2868a8bb5d85d72400 |
| hovercard-subject-tag | issue:608772973 |
| 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/38236/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ebb647eefc1a167b8f39e8b57868cd8174598a7b271d0f5aee965a8bf3d3e380/microsoft/TypeScript/issues/38236 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ebb647eefc1a167b8f39e8b57868cd8174598a7b271d0f5aee965a8bf3d3e380/microsoft/TypeScript/issues/38236 |
| og:image:alt | TypeScript Version: 3.9.1-rc/4.0.0-dev.20200428 3.9.0-beta seems to be fine. Search Terms: intersection,private,generic,constraint,union Code type Type = {foo: string} | {bar: number}; class Syncab... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vilicvane |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| 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 | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width