Title: No type inferrence of callback arguments inside a tuple union type · Issue #55632 · microsoft/TypeScript · GitHub
Open Graph Title: No type inferrence of callback arguments inside a tuple union type · Issue #55632 · microsoft/TypeScript
X Title: No type inferrence of callback arguments inside a tuple union type · Issue #55632 · microsoft/TypeScript
Description: 🔎 Search Terms discriminated union inference union argument inference 🕗 Version & Regression Information This is a compilation error in tsserver 3.3.2 ⏯ Playground Link https://www.typescriptlang.org/play?#code/C4TwDgpgBAkgdgMwgJwILIOZQL...
Open Graph Description: 🔎 Search Terms discriminated union inference union argument inference 🕗 Version & Regression Information This is a compilation error in tsserver 3.3.2 ⏯ Playground Link https://www.typescriptlang.o...
X Description: 🔎 Search Terms discriminated union inference union argument inference 🕗 Version & Regression Information This is a compilation error in tsserver 3.3.2 ⏯ Playground Link https://www.typescriptla...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/55632
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"No type inferrence of callback arguments inside a tuple union type","articleBody":"### 🔎 Search Terms\n\n- discriminated union inference \r\n- union argument inference \n\n### 🕗 Version \u0026 Regression Information\n\n- This is a compilation error in `tsserver 3.3.2` \n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play?#code/C4TwDgpgBAkgdgMwgJwILIOZQLwCgpQA+UA2gIwA0UAFAIYBcUcArgLYBGKAlDgHxQA3APYBLACYBdfEVIAmKtXaMAzsGQi4GHtn7DxEgNy4AxkLiqotTI3hI0mHKUo1a2-gG8oAX0O4gA\n\n### 💻 Code\n\n```ts\r\ntype InferArg =\r\n | [1, (a: number) =\u003e void]\r\n | [2, (b: string) =\u003e void];\r\nconst arg: InferArg = [1, (a) =\u003e { }];\r\n```\r\n\n\n### 🙁 Actual behavior\n\nI get a compilation error:\r\n\u003e Parameter 'a' implicitly has an 'any' type.(7006)\n\n### 🙂 Expected behavior\n\n`a` should be inferred to be a `number` because I already passed `1` as the first tuple element. Type inference should be identical to this code:\r\n```ts\r\ntype InferArg = [1, (a: number) =\u003e void];\r\nconst arg: InferArg = [1, (a) =\u003e { }];\r\n```\n\n### Additional information about the issue\n\n_No response_","author":{"url":"https://github.com/nenikitov","@type":"Person","name":"nenikitov"},"datePublished":"2023-09-05T00:38:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/55632/TypeScript/issues/55632"}
| 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:47632d65-2f34-8466-c561-b747dedaf08d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B208:246E06:4EC5B4:707C67:6A61EAA2 |
| html-safe-nonce | 3fd3184feaf9b08ae75e334cebd399930aa137bb9414907917d10de840e7c35e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMjA4OjI0NkUwNjo0RUM1QjQ6NzA3QzY3OjZBNjFFQUEyIiwidmlzaXRvcl9pZCI6IjM1OTAyMTQzNTYyMjY0MDI5NzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 75013af247619a10974b81cab5eecfe58c97110dac06f940277a112fbfa69cd6 |
| hovercard-subject-tag | issue:1880998153 |
| 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/55632/issue_layout |
| twitter:image | https://opengraph.githubassets.com/45dab4630f3ef5a918287c66b56ee7dba43fdc26d1d294addaa65989ab6edf49/microsoft/TypeScript/issues/55632 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/45dab4630f3ef5a918287c66b56ee7dba43fdc26d1d294addaa65989ab6edf49/microsoft/TypeScript/issues/55632 |
| og:image:alt | 🔎 Search Terms discriminated union inference union argument inference 🕗 Version & Regression Information This is a compilation error in tsserver 3.3.2 ⏯ Playground Link https://www.typescriptlang.o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nenikitov |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5dd1217fff37e297563b9d318ee02bf6378c8957c6195b77786bb8896fc9c95d |
| 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 | 554667f6dda2a53c83687de64fabc457970f0f04 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width