Title: Wrong inference from function return argument · Issue #13118 · microsoft/TypeScript · GitHub
Open Graph Title: Wrong inference from function return argument · Issue #13118 · microsoft/TypeScript
X Title: Wrong inference from function return argument · Issue #13118 · microsoft/TypeScript
Description: TypeScript Version: 2.2.0-dev.20161221 Code type SomeParams = { a: A, enter: (a: A) => void } function canYouInferThis(fn: () => SomeParams): { aa: A } { return { aa: fn().a } } const result = canYouInferThis(() => ({ a: { bla: ...
Open Graph Description: TypeScript Version: 2.2.0-dev.20161221 Code type SomeParams = { a: A, enter: (a: A) => void } function canYouInferThis(fn: () => SomeParams): { aa: A } { return { aa: fn().a } } const resu...
X Description: TypeScript Version: 2.2.0-dev.20161221 Code type SomeParams<A> = { a: A, enter: (a: A) => void } function canYouInferThis<A>(fn: () => SomeParams<A>): { aa: A } { return { a...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13118
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrong inference from function return argument","articleBody":"**TypeScript Version:** 2.2.0-dev.20161221\r\n\r\n**Code**\r\n\r\n```ts\r\ntype SomeParams\u003cA> = { a: A, enter: (a: A) => void }\r\n\r\nfunction canYouInferThis\u003cA>(fn: () => SomeParams\u003cA>): { aa: A } {\r\n return { aa: fn().a }\r\n}\r\n\r\nconst result = canYouInferThis(() => ({ a: { bla: 33 }, enter: a => undefined }))\r\nresult.aa.bla // Doesn't compile\r\n```\r\n\r\n**Expected behavior:**\r\nThe `A` parameter should be inferred to be `{ bla: number }`. It seems completely unambiguous to me.\r\nFailing that, I would expect a warning about ambiguous inferred types.\r\n\r\n\r\n**Actual behavior:**\r\nThe type of `A` is silently inferred to be `{}`\r\n","author":{"url":"https://github.com/AlexGalays","@type":"Person","name":"AlexGalays"},"datePublished":"2016-12-22T10:36:35Z","url":"https://github.com/microsoft/TypeScript/issues/13118"}
| 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:de78291f-9629-0211-bc79-556829b694fa |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 95F2:16AB79:2B85720:3759C38:6B01B0DC |
| html-safe-nonce | e809d0cae9f792a3c548054f935018e64519ddc06307aed983852c44a9df7beb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUYyOjE2QUI3OToyQjg1NzIwOjM3NTlDMzg6NkIwMUIwREMiLCJ2aXNpdG9yX2lkIjoiODA1NDc2MjUxOTA5Mjg2MDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 81d6ec7b660155d0370c7297fe123c4d92121e5e2f4086a0706338aa255c5446 |
| hovercard-subject-tag | issue:197144849 |
| 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/13118/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5b44dd463b5183618d044d9df0b0a4f963e49f37c8e2ca725c46baed16fc69c7/microsoft/TypeScript/issues/13118 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5b44dd463b5183618d044d9df0b0a4f963e49f37c8e2ca725c46baed16fc69c7/microsoft/TypeScript/issues/13118 |
| og:image:alt | TypeScript Version: 2.2.0-dev.20161221 Code type SomeParams = { a: A, enter: (a: A) => void } function canYouInferThis(fn: () => SomeParams): { aa: A } { return { aa: fn().a } } const resu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexGalays |
| 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