Title: Instantiable types from return types of contextual signatures don't provide contextual type information for return expressions · Issue #61197 · microsoft/TypeScript · GitHub
Open Graph Title: Instantiable types from return types of contextual signatures don't provide contextual type information for return expressions · Issue #61197 · microsoft/TypeScript
X Title: Instantiable types from return types of contextual signatures don't provide contextual type information for return expressions · Issue #61197 · microsoft/TypeScript
Description: 🔎 Search Terms instantiable contextual signature return types 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250216#code/C4TwDgpgBAwg...
Open Graph Description: 🔎 Search Terms instantiable contextual signature return types 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play/...
X Description: 🔎 Search Terms instantiable contextual signature return types 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/p...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/61197
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Instantiable types from return types of contextual signatures don't provide contextual type information for return expressions","articleBody":"### 🔎 Search Terms\n\ninstantiable contextual signature return types\n\n### 🕗 Version & Regression Information\n\n- This is the behavior in every version I tried\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?ts=5.8.0-dev.20250216#code/C4TwDgpgBAwg9gO2BAHsAysAhsgzlAXgCgooAfKAbxNNt22AFdcAuKAIgBs4sATASwQBzdgG4atKLxxY2CRp07jJAXxoVqk0vRzM27XIwDGRiLlxiJtadjb0AToKHLaK8UV4QjnLPegAzRgQjYH5EKCM-HAhMOD8AHgAVeCRUYAA+AAoaI0RkNDZkvLSAGhzEf34hNk1aRDYAJS843niHJxKoTJCUQpT84ABKQnSoItS0dJcVMsG2ADc4fl53XIR6KHo46AIIqORYv2zSWu0GPQ5uPid2MskbWSh5RTuoFSgsfH60zGjcV9OUHqVCspH8EGARgAFmxMsMCKNMoDJDomKwOIYTGYLK8tFIZPooRBFHBbqC3oNcW9XjMiINxEA\n\n### 💻 Code\n\n```ts\ntype ContextStates =\n | {\n status: \"loading\";\n data: null;\n }\n | {\n status: \"success\";\n data: string;\n };\n\ndeclare function createStore\u003cTContext>(\n context: TContext,\n config: {\n on: Record\u003cstring, (ctx: TContext) => TContext>;\n },\n): void;\n\nconst store = createStore(\n {\n status: \"loading\",\n data: null,\n } as ContextStates,\n {\n on: {\n fetch: () => ({\n status: \"success\",\n data: \"hello\",\n }),\n },\n },\n);\n```\n\n\n### 🙁 Actual behavior\n\n`status: \"success\",` errors\n\n### 🙂 Expected behavior\n\nno error\n\n### Additional information about the issue\n\nMaking `(ctx: TContext) => TContext` into a type parameter makes it work (see [TS playground](https://www.typescriptlang.org/play/?ts=5.8.0-dev.20250216#code/C4TwDgpgBAwg9gO2BAHsAysAhsgzlAXgCgooAfKAbxNNt22AFdcAuKAIgBs4sATASwQBzdgG4atKLxxY2CRp07jJAXxoVqk0vRzM27XIwDGRiLlxiJtadjb0AToKHLaK8UV4QjnLPegAzRgQjYH5EKCM-HAhMOD8AHhoAFXgkVGAAGmSk+ywEXH5Q8PSIBF58AAoQlDYUxGQ0AEpCAD4oOrS0LJaKmiN69NrUhsy+xH9+ITZNWkQ2ACUvON54hycM9py8gqKEFpcVLMa2ADc4fl53fvzgKHo46AIIqORYv17SGe0GPQ5uPic7Cykhssig8kUwKgKigWHww3SmGiuChXygcyoVlI-ggwCMAAs2BVmgQ2hU0ZIdExWBxDCYzBYoVopDJ9PiIIo4ECsdDGkzoVDDkRGuIgA)) but that's not natural to write and isn't broadly applicable as a workaround","author":{"url":"https://github.com/Andarist","@type":"Person","name":"Andarist"},"datePublished":"2025-02-16T20:28:06Z","url":"https://github.com/microsoft/TypeScript/issues/61197"}
| 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:fad2929f-cef8-4970-0646-038f3e97a688 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B818:1DC4CC:822909:ADBAAF:6B01AFE7 |
| html-safe-nonce | 5d54d0bdc48041e3ae6cb7c445f5fa844cbabaa5c53bb928a35be0f60cc20002 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODE4OjFEQzRDQzo4MjI5MDk6QURCQUFGOjZCMDFBRkU3IiwidmlzaXRvcl9pZCI6Ijg4ODExNjI0ODM0NTc0Mzc2NzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5fbe00bb5eee3328d66af4892eeed589000ed509fc2f565f357624687c94babb |
| hovercard-subject-tag | issue:2856314831 |
| 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/61197/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ba94febe8445e28fb8e57f42a071a174376969575346a884080056023e3edef/microsoft/TypeScript/issues/61197 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ba94febe8445e28fb8e57f42a071a174376969575346a884080056023e3edef/microsoft/TypeScript/issues/61197 |
| og:image:alt | 🔎 Search Terms instantiable contextual signature return types 🕗 Version & Regression Information This is the behavior in every version I tried ⏯ Playground Link https://www.typescriptlang.org/play/... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Andarist |
| 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