Title: Tuples are inferred as arrays, losing information · Issue #13151 · microsoft/TypeScript · GitHub
Open Graph Title: Tuples are inferred as arrays, losing information · Issue #13151 · microsoft/TypeScript
X Title: Tuples are inferred as arrays, losing information · Issue #13151 · microsoft/TypeScript
Description: TypeScript Version: 2.1.4 The inferred type of a tuple expression is an array, for example const foo = ['hello', 3, true] // foo: (string | number | boolean)[] which is a pain when what you really wanted was a tuple; you need to give a t...
Open Graph Description: TypeScript Version: 2.1.4 The inferred type of a tuple expression is an array, for example const foo = ['hello', 3, true] // foo: (string | number | boolean)[] which is a pain when what you really ...
X Description: TypeScript Version: 2.1.4 The inferred type of a tuple expression is an array, for example const foo = ['hello', 3, true] // foo: (string | number | boolean)[] which is a pain when what you...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/13151
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Tuples are inferred as arrays, losing information","articleBody":"**TypeScript Version:** 2.1.4\r\n\r\nThe inferred type of a tuple expression is an array, for example\r\n\r\n```ts\r\nconst foo = ['hello', 3, true] // foo: (string | number | boolean)[]\r\n```\r\n\r\nwhich is a pain when what you really wanted was a tuple; you need to give a type ascription in order to tell the compiler you meant it to be a tuple, e.g.\r\n\r\n```ts\r\nconst foo: [string, number, boolean] = ['hello', 3, true]\r\n```\r\n\r\nIt seems like this is wholly unnecessary, because the type `[string, number, boolean]` is assignable to `(string | number | boolean)[]`, and carries strictly more information. So the compiler is prematurely throwing away information, when it could just wait and see if later on the type needs to be specialized to an array.\r\n","author":{"url":"https://github.com/pelotom","@type":"Person","name":"pelotom"},"datePublished":"2016-12-23T22:11:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/13151/TypeScript/issues/13151"}
| 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:a374ebcf-c6f0-a03f-a325-e397b0fa381d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 957A:1E2562:27245B:370753:6A6234F3 |
| html-safe-nonce | 0277c46808dc7cab9dc9c9fc8e450aeae66f60e00bfc8557bd29609efbe3a9d2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTdBOjFFMjU2MjoyNzI0NUI6MzcwNzUzOjZBNjIzNEYzIiwidmlzaXRvcl9pZCI6IjExOTg3OTM2NTk3ODM0NjAwODMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d17c7d1f0a101a05a41d9970e2a8e149888534aacb2b396ab31a8311168e6a17 |
| hovercard-subject-tag | issue:197431774 |
| 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/13151/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7932e9f16f86e8327e7ae64240e14ce66e5031d92d59d40ec248929f9a12e33f/microsoft/TypeScript/issues/13151 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7932e9f16f86e8327e7ae64240e14ce66e5031d92d59d40ec248929f9a12e33f/microsoft/TypeScript/issues/13151 |
| og:image:alt | TypeScript Version: 2.1.4 The inferred type of a tuple expression is an array, for example const foo = ['hello', 3, true] // foo: (string | number | boolean)[] which is a pain when what you really ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pelotom |
| hostname | github.com |
| expected-hostname | github.com |
| None | f01037538d0c99e88fa8e01da1b1825ad354ff4da745198c7392a43592c8398c |
| 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 | 10b5a8861bf21b66a650f894089f8ce1476c1d49 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width