Title: `.call` on an union with different arguments counts fails when passing `any` · Issue #58468 · microsoft/TypeScript · GitHub
Open Graph Title: `.call` on an union with different arguments counts fails when passing `any` · Issue #58468 · microsoft/TypeScript
X Title: `.call` on an union with different arguments counts fails when passing `any` · Issue #58468 · microsoft/TypeScript
Description: 🔎 Search Terms call union expected arguments but got 🕗 Version & Regression Information Before version 4.5 both the .calls in the example below failed. Since then, .call(null, something-not-any) is accepted and .call(null, something-any)...
Open Graph Description: 🔎 Search Terms call union expected arguments but got 🕗 Version & Regression Information Before version 4.5 both the .calls in the example below failed. Since then, .call(null, something-not-any) is...
X Description: 🔎 Search Terms call union expected arguments but got 🕗 Version & Regression Information Before version 4.5 both the .calls in the example below failed. Since then, .call(null, something-not-any...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/58468
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`.call` on an union with different arguments counts fails when passing `any`","articleBody":"### 🔎 Search Terms\r\n\r\ncall union expected arguments but got \r\n\r\n### 🕗 Version \u0026 Regression Information\r\n\r\nBefore version 4.5 both the `.call`s in the example below failed. Since then, `.call(null, something-not-any)` is accepted and `.call(null, something-any)` failes.\r\n\r\n### ⏯ Playground Link\r\n\r\nhttps://www.typescriptlang.org/play/?ts=5.5.0-beta#code/CYUwxgNghgTiAEYD2A7AzgF3gMxQLngApCBKeAXgD54A3JAS2DIB8jCoCUBXAWwCMQMMlVoMmAKHGhIsBMnRYAHp14CYAbinhocRKkzwAngSgpDm8bgB0YKBAiFu9gDTxFJTddv3HXF0Y9JXEJDQOD3CyA\r\n\r\n### 💻 Code\r\n\r\n```ts\r\ndeclare const fn: (() =\u003e void) | ((a: number) =\u003e void)\r\n\r\ndeclare const x: number;\r\ndeclare const y: any;\r\n\r\nfn.call(null, x); // ok\r\nfn.call(null, y); // error\r\n\r\nfn(y); // ok\r\nfn(x); // ok\r\n```\r\n\r\n\r\n### 🙁 Actual behavior\r\n\r\nThe line marked as `// error` gives the following error:\r\n```\r\nExpected 1 arguments, but got 2.\r\n```\r\n\r\n### 🙂 Expected behavior\r\n\r\nIt should be accepted, the same as the other lines are accepted.\r\n\r\n### Additional information about the issue\r\n\r\n_No response_\r\n\r\n---\r\n\r\n_TODO for myself: Remove `@ts-ignore` in https://github.com/babel/babel/blob/main/packages/babel-generator/src/printer.ts#L717 once this is fixed_","author":{"url":"https://github.com/nicolo-ribaudo","@type":"Person","name":"nicolo-ribaudo"},"datePublished":"2024-05-08T10:38:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/58468/TypeScript/issues/58468"}
| 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:bf83191e-5a14-e73a-3d8e-75a97ff17174 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C56:1AEE31:14031F:1ADA2A:6A612F7A |
| html-safe-nonce | 8ac3b0877bc0b8f78a6fe34844c459f6f8d1a8b9c42b7defdccb766e84e7bf54 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzU2OjFBRUUzMToxNDAzMUY6MUFEQTJBOjZBNjEyRjdBIiwidmlzaXRvcl9pZCI6IjY4OTM4Mjg5MDU5NjUyNjg4NTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 341375d009e4d4927dbdabc363fac863f4563b4a2263b777d1d7028bd5cad9b9 |
| hovercard-subject-tag | issue:2285272658 |
| 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/58468/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3569d81c4b79f6b7f78f02b99612a3c9d2dac2b7bd2561191a346c73062b75f2/microsoft/TypeScript/issues/58468 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3569d81c4b79f6b7f78f02b99612a3c9d2dac2b7bd2561191a346c73062b75f2/microsoft/TypeScript/issues/58468 |
| og:image:alt | 🔎 Search Terms call union expected arguments but got 🕗 Version & Regression Information Before version 4.5 both the .calls in the example below failed. Since then, .call(null, something-not-any) is... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nicolo-ribaudo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6896275b704df9b9258326d49c8695aecd98d736cd9eeda7bcbb1790ac97d3ad |
| 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 | af89f6cd55841b57fa09b6b0ed9e3f8f2e94b05d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width