Title: Function argument is not infered correctly · Issue #62336 · microsoft/TypeScript · GitHub
Open Graph Title: Function argument is not infered correctly · Issue #62336 · microsoft/TypeScript
X Title: Function argument is not infered correctly · Issue #62336 · microsoft/TypeScript
Description: 🔎 Search Terms function, argument, parameter, generic, callback, infer 🕗 Version & Regression Information By trying out different versions in Playground, it looks like it works correctly in version 4.7.4 and lower ⏯ Playground Link https...
Open Graph Description: 🔎 Search Terms function, argument, parameter, generic, callback, infer 🕗 Version & Regression Information By trying out different versions in Playground, it looks like it works correctly in version...
X Description: 🔎 Search Terms function, argument, parameter, generic, callback, infer 🕗 Version & Regression Information By trying out different versions in Playground, it looks like it works correctly in ver...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/62336
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Function argument is not infered correctly","articleBody":"### 🔎 Search Terms\n\nfunction, argument, parameter, generic, callback, infer\n\n### 🕗 Version & Regression Information\n\nBy trying out different versions in Playground, it looks like it works correctly in version 4.7.4 and lower\n\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXzCgggB4AVAPgApFUAueKqBgZwxi1QHMAaeAIwZkAlPAC8FeGgDWqHAHdUwhlUHwR4yTLmKA3ACh9oSLAQp02PElQkAgjC4t4IAB4YQqYE6ioAngG0AXWp9eGsVADoo2EcGe0dRCSlUWQVUHn1lRiiImJY4hxZErRSdVAN9MDw2eDgWZAgMcQIiCBpUGjRMXHwmPjVUZABbfhAYUQBvAF9hYV0gA\n\n### 💻 Code\n\n```ts\ndeclare function call\u003cT>(fn: (a: string, b: T) => unknown): (b: T) => unknown;\n\ndeclare function fn\u003cArgs extends any[]>(\n fn: (...args: Args) => unknown,\n): (...args: Args) => unknown;\n\nconst result = call(fn(function (a, b: number) {}));\n```\n\n\n### 🙁 Actual behavior\n\nThe `a` parameter's type is `any`.\n\n### 🙂 Expected behavior\n\nThe `a` paramater's type should be `string`\n\n### Additional information about the issue\n\nI encountered this while trying to create a helper function in a codebase that uses Effect:\n\n```ts\nimport { Effect } from \"effect\"\n\nfunction call\u003cA, E, R, T = void>(fn: (a: string, b: T) => Effect.Effect\u003cA, E, R>) {\n return (b: T) => fn(\"value\", b)\n}\n\nconst fnA = call((a, b: number) => // a is `string`\n Effect.gen(function* () {\n return yield* Effect.succeed(`${a}: ${b}`)\n }),\n)\n\nconst fnB = call(\n Effect.fn(function* (a, b: number) { // a is `any`?\n return yield* Effect.succeed(`${a}: ${b}`)\n }),\n)\n```","author":{"url":"https://github.com/z4p5a9","@type":"Person","name":"z4p5a9"},"datePublished":"2025-08-26T16:48:12Z","url":"https://github.com/microsoft/TypeScript/issues/62336"}
| 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:76e3ad62-3153-3c7f-57d0-b1ab05c05a25 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ADCA:1D86C4:2CA3115:38BAB05:6B01B4DE |
| html-safe-nonce | bb6728255b450b4c51b2a88aa637c73063079b2392820a142959f5856db8ec81 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRENBOjFEODZDNDoyQ0EzMTE1OjM4QkFCMDU6NkIwMUI0REUiLCJ2aXNpdG9yX2lkIjoiMjAxMjY5OTEzMTExODY4NjM4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 823bb615cd82f761a07fc2bd7dde9009b7e6c1f44728db8ce95e7d08db9dbb6e |
| hovercard-subject-tag | issue:3356401962 |
| 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/62336/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e53928bf49e3b255adeada688d2e5327e0ae5bdab5a0a4f24ee13974badc55b9/microsoft/TypeScript/issues/62336 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e53928bf49e3b255adeada688d2e5327e0ae5bdab5a0a4f24ee13974badc55b9/microsoft/TypeScript/issues/62336 |
| og:image:alt | 🔎 Search Terms function, argument, parameter, generic, callback, infer 🕗 Version & Regression Information By trying out different versions in Playground, it looks like it works correctly in version... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | z4p5a9 |
| 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