Title: Assignability of callback parameter defined with conditional tuple type · Issue #26013 · microsoft/TypeScript · GitHub
Open Graph Title: Assignability of callback parameter defined with conditional tuple type · Issue #26013 · microsoft/TypeScript
X Title: Assignability of callback parameter defined with conditional tuple type · Issue #26013 · microsoft/TypeScript
Description: TypeScript Version: 3.1.0-dev.20180727 Code // ConditionalTuple could also return just [] in the false branch, issue still repros type ConditionalTuple
Open Graph Description: TypeScript Version: 3.1.0-dev.20180727 Code // ConditionalTuple could also return just [] in the false branch, issue still repros type ConditionalTuple
X Description: TypeScript Version: 3.1.0-dev.20180727 Code // ConditionalTuple could also return just [] in the false branch, issue still repros type ConditionalTuple<T> = [T] extends [undefined] ? [] : [T]...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/26013
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Assignability of callback parameter defined with conditional tuple type","articleBody":"**TypeScript Version:** 3.1.0-dev.20180727\r\n\r\n**Code**\r\n\r\n```ts\r\n// ConditionalTuple could also return just [] in the false branch, issue still repros\r\ntype ConditionalTuple\u003cT\u003e = [T] extends [undefined] ? [] : [T];\r\n\r\n// works fine!\r\ndeclare var f1: (...args: any[]) =\u003e void;\r\ndeclare var f2: \u003cT\u003e(...args: ConditionalTuple\u003cT\u003e) =\u003e void;\r\ndeclare var f3: (...args: ConditionalTuple\u003cnumber\u003e) =\u003e void;\r\nf2 = f1;\r\nf3 = f1;\r\n\r\n// but if we move the signatures above into a callback parameter with that signature,\r\n// assignability breaks - the types of cb are incompatible.\r\ndeclare var cb1: (cb: (...args: any[]) =\u003e void) =\u003e void;\r\ndeclare var cb2: \u003cT\u003e(cb: (...args: ConditionalTuple\u003cT\u003e) =\u003e void) =\u003e void;\r\ndeclare var cb3: (cb: (...args: ConditionalTuple\u003cnumber\u003e) =\u003e void) =\u003e void;\r\n\r\ncb2 = cb1; // can't assign to cb2\r\ncb3 = cb1; // this works though\r\n```\r\n\r\n**Expected behavior:**\r\nI am able to construct callback signatures with generic conditional types and tuples that are assignable with the maximally general callback signature (`cb1`).\r\n\r\n**Actual behavior:**\r\n`cb1` cannot be assigned to `cb2`, but removing the generic parameter ala `cb3` makes assignability work as expected.","author":{"url":"https://github.com/bterlson","@type":"Person","name":"bterlson"},"datePublished":"2018-07-27T18:25:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/26013/TypeScript/issues/26013"}
| 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:f0cfae62-3150-c9ea-b5b4-aaf883eaad80 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E5AA:1E1271:1C4CE6:26998B:6A62670A |
| html-safe-nonce | ab38a40c590f0fd7d921c0c351345bccf589c3183efc38a6386aaded198cf4b5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNUFBOjFFMTI3MToxQzRDRTY6MjY5OThCOjZBNjI2NzBBIiwidmlzaXRvcl9pZCI6IjUxNjgyNzU0Mjc3MTU4Njg0MjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6220aed3e329a21472542a58bcc786eb1bc3bc4f2fb3f1d53c190d5afd5bc0ef |
| hovercard-subject-tag | issue:345322927 |
| 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/26013/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fd5b85a84e5a3acc3f7ebfe44ae78dc1cb774a8a405f3c7d4a7fb909989e841c/microsoft/TypeScript/issues/26013 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fd5b85a84e5a3acc3f7ebfe44ae78dc1cb774a8a405f3c7d4a7fb909989e841c/microsoft/TypeScript/issues/26013 |
| og:image:alt | TypeScript Version: 3.1.0-dev.20180727 Code // ConditionalTuple could also return just [] in the false branch, issue still repros type ConditionalTuple |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bterlson |
| hostname | github.com |
| expected-hostname | github.com |
| None | 194bddaed53c0eb07047629c520853f4208e77a17ff57428346485cc202e39f2 |
| 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 | c2862cf2db52f0c7f6cba3de21ffeeafe7c5456e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width