Title: Empty tuple type now meaningful (at least, in unions) · Issue #13126 · microsoft/TypeScript · GitHub
Open Graph Title: Empty tuple type now meaningful (at least, in unions) · Issue #13126 · microsoft/TypeScript
X Title: Empty tuple type now meaningful (at least, in unions) · Issue #13126 · microsoft/TypeScript
Description: I have a situation where the only valid states for a property are [], [A], or [A, B, B], so I would like to define that property as [] | [A] | [A, B, B]. But this gives the error "A tuple element list cannot be empty," and indeed I see t...
Open Graph Description: I have a situation where the only valid states for a property are [], [A], or [A, B, B], so I would like to define that property as [] | [A] | [A, B, B]. But this gives the error "A tuple element l...
X Description: I have a situation where the only valid states for a property are [], [A], or [A, B, B], so I would like to define that property as [] | [A] | [A, B, B]. But this gives the error "A tuple elem...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13126
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Empty tuple type now meaningful (at least, in unions)","articleBody":"I have a situation where the only valid states for a property are `[]`, `[A]`, or `[A, B, B]`, so I would like to define that property as `[] | [A] | [A, B, B]`. But this gives the error \"A tuple element list cannot be empty,\" and indeed I see that there were a few prior issues relating to the compiler having (incorrectly) allowed it in the past. It seems to me that now, between overloading and unions, this type is useful. Also useful in a typeguard: `isEmpty\u003cA>(values: A[]): values is [] { return values.length === 0; }`\r\n\r\nI suppose the most difficult part of it would be actually tracking that a given array is empty, so that it could be matched against that definition.\r\n\r\nPer the checklist, the grammar is simple enough, `[]` in type positions, shouldn't have any issues with respect to JavaScript. I don't foresee any semantic issues except the above bit about actually recognizing empty arrays as such. The emit isn't affected at all, and compatibility shouldn't be an issue. I'm not rightly sure about the concerns raised in the Other section.","author":{"url":"https://github.com/krryan","@type":"Person","name":"krryan"},"datePublished":"2016-12-22T16:09:11Z","url":"https://github.com/microsoft/TypeScript/issues/13126"}
| 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:b50208bc-d53a-20f7-c2d8-b259aa6166fb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D54C:B1B84:E03CE:11CC6C:6B00F75D |
| html-safe-nonce | fab4a4e1371dbfa4b17ad1ecb246e299ee595bc3e0e9b642ef7ecf329faf11f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTRDOkIxQjg0OkUwM0NFOjExQ0M2Qzo2QjAwRjc1RCIsInZpc2l0b3JfaWQiOiIxNzg1MTM2MTc0MDY3Njc3MDIxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e4c010a9a5c1b067773a3c239db3e63e3aa79a811c25b0e8d15418545ce31834 |
| hovercard-subject-tag | issue:197208176 |
| 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/13126/issue_layout |
| twitter:image | https://opengraph.githubassets.com/da31476766bf8163ee3936fcd21102ca31d904ada34ceac323dbdc449f6ba743/microsoft/TypeScript/issues/13126 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/da31476766bf8163ee3936fcd21102ca31d904ada34ceac323dbdc449f6ba743/microsoft/TypeScript/issues/13126 |
| og:image:alt | I have a situation where the only valid states for a property are [], [A], or [A, B, B], so I would like to define that property as [] | [A] | [A, B, B]. But this gives the error "A tuple element l... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | krryan |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width