Title: Incorrect Generic compatibility report · Issue #29062 · microsoft/TypeScript · GitHub
Open Graph Title: Incorrect Generic compatibility report · Issue #29062 · microsoft/TypeScript
X Title: Incorrect Generic compatibility report · Issue #29062 · microsoft/TypeScript
Description: TypeScript Version: 3.2.2 Search Terms: Code It is a common situation that provides some default params to required options and make them be optional to bring convenient calling usage. interface HasHeight { height: number } type Omit
Open Graph Description: TypeScript Version: 3.2.2 Search Terms: Code It is a common situation that provides some default params to required options and make them be optional to bring convenient calling usage. interface Ha...
X Description: TypeScript Version: 3.2.2 Search Terms: Code It is a common situation that provides some default params to required options and make them be optional to bring convenient calling usage. interface Ha...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29062
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect Generic compatibility report","articleBody":"\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.2.2\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\r\n**Code**\r\nIt is a common situation that provides some default params to required options and make them be optional to bring convenient calling usage.\r\n\r\n```ts\r\ninterface HasHeight { \r\n height: number\r\n}\r\n\r\ntype Omit\u003cP, K extends keyof P> = Pick\u003cP, Exclude\u003ckeyof P, K>>\r\n\r\nfunction makeHeightOptional\u003cP extends HasHeight>(heightRequired: (p: P) => number) {\r\n return function heightOptional(params: Omit\u003cP, 'height'> & { height?: number }) {\r\n const height = params.height || 10\r\n const newParams = { ...params, height }\r\n\r\n // Argument of type 'Pick\u003cP, Exclude\u003ckeyof P, \"height\">> & { height: number; }' is not assignable to parameter of type 'P'.\r\n return heightRequired(newParams)\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\ncode works\r\n\r\n**Actual behavior:**\r\n\r\nTS report:\r\n```\r\nArgument of type 'Pick\u003cP, Exclude\u003ckeyof P, \"height\">> & { height: number; }' is not assignable to parameter of type 'P'.\r\n```\r\n\r\n**Playground Link:** http://www.typescriptlang.org/play/index.html#src=interface%20HasHeight%20%7B%20%0A%20%20height%3A%20number%0A%7D%0A%0Atype%20Omit%3CP%2C%20K%20extends%20keyof%20P%3E%20%3D%20Pick%3CP%2C%20Exclude%3Ckeyof%20P%2C%20K%3E%3E%0A%0Afunction%20makeHeightOptional%3CP%20extends%20HasHeight%3E(heightRequired%3A%20(p%3A%20P)%20%3D%3E%20number)%20%7B%0A%20%20return%20function%20heightOptional(params%3A%20Omit%3CP%2C%20'height'%3E%20%26%20%7B%20height%3F%3A%20number%20%7D)%20%7B%0A%20%20%20%20const%20height%20%3D%20params.height%20%7C%7C%2010%0A%20%20%20%20const%20newParams%20%3D%20%7B%20...params%2C%20height%20%7D%0A%0A%20%20%20%20return%20heightRequired(newParams)%0A%20%20%7D%0A%7D%0A%0A\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/zheeeng","@type":"Person","name":"zheeeng"},"datePublished":"2018-12-17T17:13:36Z","url":"https://github.com/microsoft/TypeScript/issues/29062"}
| 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:b4a7e6dd-06e3-153b-90c6-48f9c63951a5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9F2:1F927B:8468C7:AEAE9E:6B01ADB5 |
| html-safe-nonce | 8f5c42b924b0a56e30e16c55138ebb89f8dd1075ab30f7b57ef7f96d13f0f9f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUYyOjFGOTI3Qjo4NDY4Qzc6QUVBRTlFOjZCMDFBREI1IiwidmlzaXRvcl9pZCI6IjU5MTUzMjcyNDMwMzAyMTIwMjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f85dc0921e7dd7885a1157e5eef1bd96e7f385003099e6c5f544351f656823d0 |
| hovercard-subject-tag | issue:391809722 |
| 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/29062/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b9c3f3a0ee635277bc4e6a954e5854a5d0bf5b7395e25a6a948d651027698cb8/microsoft/TypeScript/issues/29062 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b9c3f3a0ee635277bc4e6a954e5854a5d0bf5b7395e25a6a948d651027698cb8/microsoft/TypeScript/issues/29062 |
| og:image:alt | TypeScript Version: 3.2.2 Search Terms: Code It is a common situation that provides some default params to required options and make them be optional to bring convenient calling usage. interface Ha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zheeeng |
| 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