Title: Inferred return type of a generic function with destructure incorrectly retains generics · Issue #33823 · microsoft/TypeScript · GitHub
Open Graph Title: Inferred return type of a generic function with destructure incorrectly retains generics · Issue #33823 · microsoft/TypeScript
X Title: Inferred return type of a generic function with destructure incorrectly retains generics · Issue #33823 · microsoft/TypeScript
Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Inferred return type of a generic function with destructure incorrectly retains generics · Issue #33823 · microsoft/TypeScript
Open Graph Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Inferred return type of a generic function with destructure incorrectly retains generics · Issue #33823 · microsof...
X Description: TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Inferred return type of a generic function with destructure incorrectly retains generics · Issue #33823 · microsof...
Opengraph URL: https://github.com/microsoft/TypeScript
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inferred return type of a generic function with destructure incorrectly retains generics","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.6.3, 3.7-Beta\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 function infer return type\r\n- generic function destructure\r\n\r\n**Code**\r\n\r\nMinimal reproducible example:\r\n\r\n```ts\r\ninterface TestGeneric\u003cTG> {\r\n f: string\r\n g: TG\r\n}\r\n\r\nconst removeF = \u003cTX>({ f, ...rest }: TestGeneric\u003cTX>) => {\r\n return rest\r\n}\r\n\r\nconst result: number = removeF\u003cnumber>({ f: '', g: 3 }).g\r\n```\r\n\r\n**Expected behavior:**\r\n\r\nNo type errors\r\n\r\n**Actual behavior:**\r\n\r\n```\r\nType 'TX' is not assignable to type 'number'\r\n```\r\n\r\n**Playground Link:** \u003c!-- A link to a TypeScript Playground \"Share\" link which demonstrates this behavior -->\r\nhttps://www.typescriptlang.org/play/index.html?ts=3.7-Beta&ssl=10&ssc=58&pln=1&pc=1#code/JYOwLgpgTgZghgYwgAgCoQM5gOIRNYBAHlWwD5kBvAWAChlkYAuZLKUAczoY5dLoC+dOggD2ILMigQAtqIBuEAGLIAvMhIANMgApKjADTIAdKemSBfTDjwFiqbQEo1FGvSkQwAVyggPWQWFaMQkwfy8AGzAWEC8ZACNoNQ85RSUiWIToXX1mZAByfKNeZABmZAFHYy5aIA\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? --> #33579 #28234\r\n","author":{"url":"https://github.com/syy1125","@type":"Person","name":"syy1125"},"datePublished":"2019-10-04T23:42:23Z","url":"https://github.com/microsoft/TypeScript/issues/33823"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:49c530d9-a20a-4395-e177-3366a8276767 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C292:27D3AD:2EC3C83:3B61A65:6B01BDFF |
| html-safe-nonce | 54430db42e625b78eccfd8aa7a06718cc4288e45aaa0cae996ecadf0dcfcafe0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjkyOjI3RDNBRDoyRUMzQzgzOjNCNjFBNjU6NkIwMUJERkYiLCJ2aXNpdG9yX2lkIjoiNDQwNTAwMTI0MTc3MjUzOTM5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd6853a00b672c507843be9e7c85592cf69819c1b5a169b535631c1a72f42447 |
| hovercard-subject-tag | repository:20929025 |
| 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/microsoft/TypeScript/issues/33823 |
| twitter:image | https://opengraph.githubassets.com/47cde802d3847ff7ce61448bd4f8c3272d012c9a3f2b9085b71a67530bf7bbd6/microsoft/TypeScript |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/47cde802d3847ff7ce61448bd4f8c3272d012c9a3f2b9085b71a67530bf7bbd6/microsoft/TypeScript |
| og:image:alt | TypeScript is a superset of JavaScript that compiles to clean JavaScript output. - Inferred return type of a generic function with destructure incorrectly retains generics · Issue #33823 · microsof... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-cache |
| 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