Title: cannot auto parse right type in these code · Issue #13844 · microsoft/TypeScript · GitHub
Open Graph Title: cannot auto parse right type in these code · Issue #13844 · microsoft/TypeScript
X Title: cannot auto parse right type in these code · Issue #13844 · microsoft/TypeScript
Description: TypeScript Version: 2.1.4 Code function mergeObject
Open Graph Description: TypeScript Version: 2.1.4 Code function mergeObject
X Description: TypeScript Version: 2.1.4 Code function mergeObject<T extends any>(dst: T, src: T): T { for (var x in src) { dst[x] = src[x]; } return dst; } interface Hash<T> { [key: string]: T; } typ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13844
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"cannot auto parse right type in these code","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**TypeScript Version:** 2.1.4\r\n\r\n**Code**\r\n```ts\r\nfunction mergeObject\u003cT extends any>(dst: T, src: T): T\r\n{\r\n for (var x in src)\r\n {\r\n dst[x] = src[x];\r\n }\r\n return dst;\r\n}\r\n \r\ninterface Hash\u003cT> { [key: string]: T; }\r\n\r\ntype EventHandler = (s: BaseEventDealer) => void;\r\ninterface BaseEventDealer\r\n{\r\n GetEventHandler(event: string): EventHandler;\r\n}\r\n\r\nclass C implements BaseEventDealer\r\n{\r\n GetEventHandler(event: string) { return C.h[event]; }\r\n\r\n static h : Hash\u003cEventHandler> = {\r\n a:function(s){}\r\n }\r\n}\r\n\r\nclass D extends C\r\n{\r\n GetEventHandler(event: string) { return D.h[event]; }\r\n static h = mergeObject\u003cHash\u003cEventHandler>>(\r\n {\r\n b:function(s:D){}\r\n },C.h);\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\n\r\ntype of D.h should be Hash\\\u003cEventHandler>\r\ntype of return value of D.GetEventHandler should be EventHandler\r\n\r\n**Actual behavior:**\r\n\r\ntype of D.h and return value of D.GetEventHandler both is ImplicitAny\r\nbut if you remove D.GetEventHandler or change its name, h will get right type\r\nor you manually declare h:Hash\\\u003cEventHandler> or GetEventHandler(event: string):EventHandler, they will both get right type\r\n\r\n","author":{"url":"https://github.com/ktangels","@type":"Person","name":"ktangels"},"datePublished":"2017-02-02T18:21:42Z","url":"https://github.com/microsoft/TypeScript/issues/13844"}
| 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:524f271f-00f8-1d65-588b-878531319e77 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BB70:17FB7:29B46F:34911E:6B010041 |
| html-safe-nonce | 2f6e4a982685ce0e6053146d24122476a3c7caeeffce5938fbdc0aac1ebeb431 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQjcwOjE3RkI3OjI5QjQ2RjozNDkxMUU6NkIwMTAwNDEiLCJ2aXNpdG9yX2lkIjoiODU1MzIwMTE2NDQ0MTY4MTk4NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1c1e53a676c4df7abc69dbd2736aa0964820fc60cea5d366c197a7a253172561 |
| hovercard-subject-tag | issue:204955193 |
| 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/13844/issue_layout |
| twitter:image | https://opengraph.githubassets.com/63fb4a4c3b141899a517c133eb5aeb6954da46d7fd7544972d688f04ac97f177/microsoft/TypeScript/issues/13844 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/63fb4a4c3b141899a517c133eb5aeb6954da46d7fd7544972d688f04ac97f177/microsoft/TypeScript/issues/13844 |
| og:image:alt | TypeScript Version: 2.1.4 Code function mergeObject |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ktangels |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width