Title: Nested callbacks are not contextually typed with a type parameter dependent type query · Issue #52575 · microsoft/TypeScript · GitHub
Open Graph Title: Nested callbacks are not contextually typed with a type parameter dependent type query · Issue #52575 · microsoft/TypeScript
X Title: Nested callbacks are not contextually typed with a type parameter dependent type query · Issue #52575 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms nested callbacks contextual types 🕗 Version & Regression Information This changed between versions 5.0.0-dev.20221216 and 5.0.0-dev.20221217 ⏯ Playground Link Playground link with relevant code 💻 Code export int...
Open Graph Description: Bug Report 🔎 Search Terms nested callbacks contextual types 🕗 Version & Regression Information This changed between versions 5.0.0-dev.20221216 and 5.0.0-dev.20221217 ⏯ Playground Link Playground l...
X Description: Bug Report 🔎 Search Terms nested callbacks contextual types 🕗 Version & Regression Information This changed between versions 5.0.0-dev.20221216 and 5.0.0-dev.20221217 ⏯ Playground Link Playgrou...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/52575
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Nested callbacks are not contextually typed with a type parameter dependent type query","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\nnested callbacks contextual types\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This changed between versions 5.0.0-dev.20221216 and 5.0.0-dev.20221217\r\n\r\n\r\n### ⏯ Playground Link\r\n\r\n\u003c!--\r\n A link to a TypeScript Playground \"Share\" link which shows this behavior\r\n\r\n The TypeScript Workbench can be used for more complex setups, try\r\n https://www.typescriptlang.org/dev/bug-workbench/\r\n\r\n As a last resort, you can link to a repo, but these will be slower for us to investigate.\r\n-->\r\n[Playground link with relevant code](https://www.typescriptlang.org/play?ts=5.0.0-dev.20221217&ssl=23&ssc=1&pln=1&pc=1#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgUQDdgUAeAFQD44BvAKDkbm0wBtWAjHAawC44AFFGABnSEhHB+5AJRwAvNUIQEAEwDcDJklGpV-ekyPM2nHvyGjxk6XMVxlazUYC+dN3VCRYcGAE8wPABhAFcRGAgAWyISGBEFWi1GTH4YsnCoZABzSiS4DlTiMiQQyI40agB6SrgASXQ4CCRWP0adEyRVNUxUXwC8UARw+IR4AHdobhF3TTpVYGxWTGE4dBCkbBgEJrhgSNGKXZBUTvjuYD8IBtDwqLS4ygF-QOkAGjhVHpS4G4jooriAG1yABdGT8RyqOiefYwAQAckw8PehiYLHYXGwfEEUDs1BoLne1TgUEQ8Qy2UQSDgABYAHQATjgmE6cAArHSAAx5HThYD6RLGNGmTHYoR42hwYmkoZwClILJU2mM5mslm7KBQaBKjncvKuV55QnuGSaIA)\r\n\r\n### 💻 Code\r\n\r\n\u003c!-- Please post the relevant code sample here as well-->\r\n```ts\r\nexport interface Event\u003cT> {\r\n callback: (response: T) => void;\r\n nested: {\r\n callback: (response: T) => void;\r\n }\r\n}\r\n\r\nexport type CustomEvents = {\r\n a: Event\u003cstring>\r\n b: Event\u003cnumber> // If only one candidate type exists it works\r\n};\r\n\r\ndeclare function emit\u003cT extends keyof CustomEvents>(type: T, data: CustomEvents[T]): void\r\n\r\nemit('a', {\r\n callback: (r) => {}, // r is string in 4.9 and 5.0\r\n nested: {\r\n callback: (r) => { // r is string in 4.9 and an error in 5.0\r\n\r\n },\r\n },\r\n});\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nThe parameter of the callback in nested is not typed and gives an error : Parameter 'r' implicitly has an 'any' type.\r\n\r\n### 🙂 Expected behavior\r\n\r\nThe parameter of the callback in nested is typed as string, same as in 4.9 and same as for the top level callback\r\n","author":{"url":"https://github.com/dragomirtitian","@type":"Person","name":"dragomirtitian"},"datePublished":"2023-02-02T17:00:31Z","url":"https://github.com/microsoft/TypeScript/issues/52575"}
| 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:37bf58f6-083a-ea8f-593a-9fb9cf054678 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6EE:EA06E:2D7322E:39CB6D8:6B01A00C |
| html-safe-nonce | 503f6d9edac65037ca163ce309665e177aeabf5a9e590c14da707a28f4a4294f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkVFOkVBMDZFOjJENzMyMkU6MzlDQjZEODo2QjAxQTAwQyIsInZpc2l0b3JfaWQiOiI1MTMxNDY0MjU5NDY0Njk5OTE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 700fbfcdc7cad0e067202cb8d209c113d45f98890cbd33fc63c26c26abe2e875 |
| hovercard-subject-tag | issue:1568413909 |
| 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/52575/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b58af288f3793228209faa029ac829017a5b07298584c33021ce53a865ad1ae1/microsoft/TypeScript/issues/52575 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b58af288f3793228209faa029ac829017a5b07298584c33021ce53a865ad1ae1/microsoft/TypeScript/issues/52575 |
| og:image:alt | Bug Report 🔎 Search Terms nested callbacks contextual types 🕗 Version & Regression Information This changed between versions 5.0.0-dev.20221216 and 5.0.0-dev.20221217 ⏯ Playground Link Playground l... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dragomirtitian |
| 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