Title: Assignment of a partial type member to an intersection type including the partial does not compile in 2.7.0-dev.20180112 · Issue #21170 · microsoft/TypeScript · GitHub
Open Graph Title: Assignment of a partial type member to an intersection type including the partial does not compile in 2.7.0-dev.20180112 · Issue #21170 · microsoft/TypeScript
X Title: Assignment of a partial type member to an intersection type including the partial does not compile in 2.7.0-dev.20180112 · Issue #21170 · microsoft/TypeScript
Description: TypeScript Version: 2.7.0-dev.20180112 Code interface IX { x: boolean; } function fn
Open Graph Description: TypeScript Version: 2.7.0-dev.20180112 Code interface IX { x: boolean; } function fn
X Description: TypeScript Version: 2.7.0-dev.20180112 Code interface IX { x: boolean; } function fn<T>(obj: T, props: Partial<T>): (T & IX) { const xobj = obj as T & IX; xobj.x = true; for (co...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/21170
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Assignment of a partial type member to an intersection type including the partial does not compile in 2.7.0-dev.20180112","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\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 2.7.0-dev.20180112\r\n\r\n**Code**\r\n\r\n```ts\r\ninterface IX {\r\n x: boolean;\r\n}\r\n\r\nfunction fn\u003cT>(obj: T, props: Partial\u003cT>): (T & IX) {\r\n const xobj = obj as T & IX;\r\n xobj.x = true;\r\n for (const p in props) {\r\n // The following line causes a compilation error:\r\n // TS2322: Type 'Partial\u003cT>[keyof T]' is not assignable to type '(T & IX)[keyof T]'.\r\n xobj[p] = props[p];\r\n }\r\n return xobj;\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nThis should compile since the members of `Partial\u003cT>` is a subset of the members of `(T & IX)`.\r\nThis does compile in 2.7.0-dev.20180108.\r\n\r\n\r\n**Actual behavior:**\r\nThe following error is emitted when compiled:\r\n```\r\nindex.ts(9,9): error TS2322: Type 'Partial\u003cT>[keyof T]' is not assignable to type '(T & IX)[keyof T]'.\r\n Type 'T[keyof T]' is not assignable to type '(T & IX)[keyof T]'.\r\n Type 'T' is not assignable to type 'T & IX'.\r\n Type 'T' is not assignable to type 'IX'.\r\n```\r\n**Related:**\r\n","author":{"url":"https://github.com/athasach","@type":"Person","name":"athasach"},"datePublished":"2018-01-12T21:23:19Z","url":"https://github.com/microsoft/TypeScript/issues/21170"}
| 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:d0ad823c-8a81-1051-cdbb-1ecf14a817b8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DE2C:34CAB:A9FDDC:DA232F:6B00F850 |
| html-safe-nonce | 7684d9fe22732c250f64ce44f2eec6f6028f6410f772882222d01db731373d85 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTJDOjM0Q0FCOkE5RkREQzpEQTIzMkY6NkIwMEY4NTAiLCJ2aXNpdG9yX2lkIjoiMTc4OTU3MDA1MzQ5MDkzMTc5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cbd8c96a4908b9d69ad01d32def60749533fd941562a70d71b3f6a699e5db2e0 |
| hovercard-subject-tag | issue:288250030 |
| 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/21170/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e4c1dfcfab05c837b20bbac16b90418975dc39d04320cd3391949c08c6f18e58/microsoft/TypeScript/issues/21170 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e4c1dfcfab05c837b20bbac16b90418975dc39d04320cd3391949c08c6f18e58/microsoft/TypeScript/issues/21170 |
| og:image:alt | TypeScript Version: 2.7.0-dev.20180112 Code interface IX { x: boolean; } function fn |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | athasach |
| 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