Title: Can't assign existing property to the rest of generic · Issue #28952 · microsoft/TypeScript · GitHub
Open Graph Title: Can't assign existing property to the rest of generic · Issue #28952 · microsoft/TypeScript
X Title: Can't assign existing property to the rest of generic · Issue #28952 · microsoft/TypeScript
Description: TypeScript Version: 3.2.2 and 3.3.0-dev.20181208 Search Terms: generic pick exclude spread Code interface AB { a: string; b: string; } function excludeA
Open Graph Description: TypeScript Version: 3.2.2 and 3.3.0-dev.20181208 Search Terms: generic pick exclude spread Code interface AB { a: string; b: string; } function excludeA
X Description: TypeScript Version: 3.2.2 and 3.3.0-dev.20181208 Search Terms: generic pick exclude spread Code interface AB { a: string; b: string; } function excludeA<T extends AB>(obj: T) { const {a, ...r...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/28952
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Can't assign existing property to the rest of generic","articleBody":"\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.2.2 and 3.3.0-dev.20181208\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\n- generic\r\n- pick\r\n- exclude\r\n- spread\r\n\r\n**Code**\r\n```ts\r\ninterface AB {\r\n a: string;\r\n b: string;\r\n}\r\n\r\nfunction excludeA\u003cT extends AB>(obj: T) {\r\n const {a, ...rest} = obj;\r\n\r\n rest.b = '3';\r\n\r\n return rest;\r\n}\r\n\r\nexcludeA({ a: '1', b: '2', c: 'test' });\r\n```\r\n\r\n**Expected behavior:**\r\nNo errors\r\n\r\n**Actual behavior:**\r\n`Property 'b' does not exist on type 'Pick\u003cT, Exclude\u003ckeyof T, \"a\">>'.`\r\n\r\n**Playground Link:** \r\nhttps://www.typescriptlang.org/play/index.html#src=interface%20AB%20%7B%0D%0A%20%20a%3A%20string%3B%0D%0A%20%20b%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Afunction%20excludeA%3CT%20extends%20AB%3E(obj%3A%20T)%20%7B%0D%0A%20%20const%20%7Ba%2C%20...rest%7D%20%3D%20obj%3B%0D%0A%0D%0A%20%20rest.b%20%3D%20'3'%3B%0D%0A%0D%0A%20%20return%20rest%3B%0D%0A%7D%0D%0A%0D%0AexcludeA(%7B%20a%3A%20'1'%2C%20b%3A%20'2'%2C%20c%3A%20'test'%20%7D)%3B\r\n\r\n**Related**\r\nhttps://github.com/Microsoft/TypeScript/issues/28821","author":{"url":"https://github.com/klimashkin","@type":"Person","name":"klimashkin"},"datePublished":"2018-12-11T02:45:44Z","url":"https://github.com/microsoft/TypeScript/issues/28952"}
| 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:ffab03a0-05ae-7fe0-b65a-c266a1ddc90a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D8F4:2E7EBB:31E68F7:3F2F855:6B01C687 |
| html-safe-nonce | 2dca70a74b4edfbe700080c6327b7a5aba5ef1c260c9424ce45d5fc3989fcac7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOEY0OjJFN0VCQjozMUU2OEY3OjNGMkY4NTU6NkIwMUM2ODciLCJ2aXNpdG9yX2lkIjoiNjA2MDY1MjI1ODk2ODg0ODAwNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7df282177fcc543d312ba8da69ea8dc8e13b4e94965f4b321a23872ffd2d1715 |
| hovercard-subject-tag | issue:389573464 |
| 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/28952/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7a5dd965e2ba7cac2a69e04e8ab1a530f17b705eb06f23c14dd6ed57c8452f4c/microsoft/TypeScript/issues/28952 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7a5dd965e2ba7cac2a69e04e8ab1a530f17b705eb06f23c14dd6ed57c8452f4c/microsoft/TypeScript/issues/28952 |
| og:image:alt | TypeScript Version: 3.2.2 and 3.3.0-dev.20181208 Search Terms: generic pick exclude spread Code interface AB { a: string; b: string; } function excludeA |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | klimashkin |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width