Title: Inconsistent treatment of shorthand methods with generic Partial · Issue #32416 · microsoft/TypeScript · GitHub
Open Graph Title: Inconsistent treatment of shorthand methods with generic Partial · Issue #32416 · microsoft/TypeScript
X Title: Inconsistent treatment of shorthand methods with generic Partial · Issue #32416 · microsoft/TypeScript
Description: TypeScript Version: 3.5.1 Search Terms: inconsistent shorthand methods Code function assignPartial
Open Graph Description: TypeScript Version: 3.5.1 Search Terms: inconsistent shorthand methods Code function assignPartial
X Description: TypeScript Version: 3.5.1 Search Terms: inconsistent shorthand methods Code function assignPartial<T>(target: T, partial: Partial<T>): T { return Object.assign(target, partial) } let ob...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/32416
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent treatment of shorthand methods with generic Partial","articleBody":"**TypeScript Version:** 3.5.1\r\n\r\n**Search Terms:** inconsistent shorthand methods\r\n\r\n**Code**\r\n\r\n```ts\r\nfunction assignPartial\u003cT>(target: T, partial: Partial\u003cT>): T {\r\n return Object.assign(target, partial)\r\n}\r\n\r\nlet obj = {\r\n foo(bar: string) {}\r\n}\r\n\r\nassignPartial(obj, {foo: (...args) => {}})\r\nassignPartial(obj, {foo(...args) {}})\r\n```\r\n\r\n**Expected behavior:**\r\nBoth calls to assignPartial are typechecked the same, with no `any` types or errors.\r\n\r\n**Actual behavior:**\r\nIn the second call, `args` is given the type `any[]`, causing `noImplicitAny` to fail.\r\n\r\n**Additional notes:**\r\n- If you change `Partial\u003cT>` to just `T`, the error goes away ([playground link](https://www.typescriptlang.org/play/#code/ATBmFcDsGMBcEsD2lgEMDO74HNIAVUAnBVAGwB4AVAPgApEAjAKwC5hKAaYAByJNLaUAlIOABvAFAgQhAKaxwhFAHlmsuADoMWXPWZdexeGSFTgAXzNnS84IybAAvOLMhQiRLQZE26WIXhIbCFxSxBLM20cfD5jUj0mLjF3RDZaDQyibHQQx2pQ81MQKNwCIzIEpJT0zMJskLFzQokgA)).\r\n- If you keep `Partial` but hardcode the type instead of using generics, the error also goes away ([playground link](https://www.typescriptlang.org/play/#code/ATBmFcDsGMBcEsD2lgEMDO74HNIAVUAnBVAGwApYjsBTWALmFgE8AHGxUYRAIwCsANMFZESpRgWLwyAHhbtO3fgD4AlI3kcuvPsADeAKBAhCdcIRQB5fjTgA6DFlyVqdISKllVR4AF8fPqR0SroAvPo+IKCIiOQ8RIzosITwkNiq+v4g-j6OOPii0hQ6QnrRiIzkdtXU6Bmhypm+3iB5uJJi5CX65VU1hNh1Td5AA)).\r\n\r\n**Playground Link:** \r\nhttps://www.typescriptlang.org/play/#code/ATBmFcDsGMBcEsD2lgEMDO74HNIAVUAnBVAGwB4AVAPgApYjsBTWALmEoBpgAHIk0uwLF4ZKtQCU7SsADeAKBAhCLcIRQB5AEYArJnAB0GLLnqMW3PiLITFwAL527pFsES7gAXjl2QoRIi0WkTs6LCE8JDYEnKOII52xjj4-KKktO463LL+iOy0BoWM6DGe1LH2tiBJuMICGbrZuQVFhNglFbZAA\r\n\r\n**Related Issues:** https://github.com/microsoft/TypeScript/issues/11062, but it's a different inconsistency (and has been fixed).\r\n","author":{"url":"https://github.com/russelldavis","@type":"Person","name":"russelldavis"},"datePublished":"2019-07-16T05:06:43Z","url":"https://github.com/microsoft/TypeScript/issues/32416"}
| 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:a8e090a5-5ec6-1463-2905-2ba4ceff469f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D1B2:1EC9BC:2B9C44A:379CAA2:6B01B6B8 |
| html-safe-nonce | 8a489aa6359a88a32b60e5097087252afec00f89c74a8d2df65ede880e430600 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMUIyOjFFQzlCQzoyQjlDNDRBOjM3OUNBQTI6NkIwMUI2QjgiLCJ2aXNpdG9yX2lkIjoiMTAxMDMxNDE0ODE5OTkwNDk1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8ed247704d0d5ba613b1cbd067d67a8c0385839e99c6f0cb0e15947663044917 |
| hovercard-subject-tag | issue:468449493 |
| 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/32416/issue_layout |
| twitter:image | https://opengraph.githubassets.com/000273fad200016c5d220aeb1db4530a7b10ab66875a0e4fa5087a2aa3d33cde/microsoft/TypeScript/issues/32416 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/000273fad200016c5d220aeb1db4530a7b10ab66875a0e4fa5087a2aa3d33cde/microsoft/TypeScript/issues/32416 |
| og:image:alt | TypeScript Version: 3.5.1 Search Terms: inconsistent shorthand methods Code function assignPartial |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | russelldavis |
| 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