Title: Regression: Intersection of array and tuple not assignable to tuple · Issue #38348 · microsoft/TypeScript · GitHub
Open Graph Title: Regression: Intersection of array and tuple not assignable to tuple · Issue #38348 · microsoft/TypeScript
X Title: Regression: Intersection of array and tuple not assignable to tuple · Issue #38348 · microsoft/TypeScript
Description: TypeScript Version: Nightly Search Terms: tuple intersection array Expected behavior: Expected code to compile. It does compile with tsc 3.8, but does not compile with tsc 3.9 (Nightly). Actual behavior: In the code below, the following ...
Open Graph Description: TypeScript Version: Nightly Search Terms: tuple intersection array Expected behavior: Expected code to compile. It does compile with tsc 3.8, but does not compile with tsc 3.9 (Nightly). Actual beh...
X Description: TypeScript Version: Nightly Search Terms: tuple intersection array Expected behavior: Expected code to compile. It does compile with tsc 3.8, but does not compile with tsc 3.9 (Nightly). Actual beh...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38348
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Regression: Intersection of array and tuple not assignable to tuple","articleBody":"**TypeScript Version:** Nightly\r\n\r\n**Search Terms:** tuple intersection array\r\n\r\n**Expected behavior:**\r\nExpected code to compile. It does compile with `tsc` 3.8, but does *not* compile with `tsc` 3.9 (Nightly).\r\n\r\n**Actual behavior:**\r\nIn the code below, the following error is reported:\r\n```ts\r\nconst x: [number, ...number[]]\r\nType 'number[] & [number, ...number[]]' is not assignable to type '[number, ...number[]]'.(2322)\r\n```\r\n\r\n**Code**\r\n```ts\r\nconst y: number[] & [number, ...number[]] = [1];\r\nconst x: [number, ...number[]] = y;\r\n```\r\n\r\n**Discussion**\r\n\r\nPresumably, this is related to the breaking change in 3.9 around handling of tuple types more strictly. I believe the code is correct however and _should_ compile, because the array type `number[]` is a strict supertype of the tuple type `[number, ...number[]]` (surely?) - perhaps the special case unifying tuple types with matching element types to an array type hasn't been implemented?\r\n\r\nDiscovered by @JasonGore and @NWilson (MSFT).\r\n\r\n\r\n\u003cdetails>\u003csummary>\u003cb>Output\u003c/b>\u003c/summary>\r\n\r\n```ts\r\n\"use strict\";\r\nconst y = [1];\r\nconst x = y;\r\n\r\n```\r\n\r\n\r\n\u003c/details>\r\n\r\n\r\n\u003cdetails>\u003csummary>\u003cb>Compiler Options\u003c/b>\u003c/summary>\r\n\r\n```json\r\n{\r\n \"compilerOptions\": {\r\n \"noImplicitAny\": true,\r\n \"strictNullChecks\": true,\r\n \"strictFunctionTypes\": true,\r\n \"strictPropertyInitialization\": true,\r\n \"strictBindCallApply\": true,\r\n \"noImplicitThis\": true,\r\n \"noImplicitReturns\": true,\r\n \"useDefineForClassFields\": false,\r\n \"alwaysStrict\": true,\r\n \"allowUnreachableCode\": false,\r\n \"allowUnusedLabels\": false,\r\n \"downlevelIteration\": false,\r\n \"noEmitHelpers\": false,\r\n \"noLib\": false,\r\n \"noStrictGenericChecks\": false,\r\n \"noUnusedLocals\": false,\r\n \"noUnusedParameters\": false,\r\n \"esModuleInterop\": true,\r\n \"preserveConstEnums\": false,\r\n \"removeComments\": false,\r\n \"skipLibCheck\": false,\r\n \"checkJs\": false,\r\n \"allowJs\": false,\r\n \"declaration\": true,\r\n \"experimentalDecorators\": false,\r\n \"emitDecoratorMetadata\": false,\r\n \"target\": \"ES2017\",\r\n \"module\": \"ESNext\"\r\n }\r\n}\r\n```\r\n\r\n\r\n\u003c/details>\r\n\r\n**Playground Link:** [Provided](https://www.typescriptlang.org/play/index.html?ts=Nightly#code/MYewdgzgLgBAngLhmArgWwEYFMBOBtAXRgDIY9VNcAaGAOnou3wKIF4yBGAgbgFgAoUJFgAPJOXRMa9Wo1yE28bkA)\r\n ","author":{"url":"https://github.com/NWilson","@type":"Person","name":"NWilson"},"datePublished":"2020-05-05T21:07:15Z","url":"https://github.com/microsoft/TypeScript/issues/38348"}
| 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:ccbf06b9-fb3f-f5ab-9aba-688396f270ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AECA:3DD488:6803E1:85D8AC:6B00E125 |
| html-safe-nonce | 4c34b639a829bf29810041322cd2ad6ddaaf295341a0591a7e95315466c66f0d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRUNBOjNERDQ4ODo2ODAzRTE6ODVEOEFDOjZCMDBFMTI1IiwidmlzaXRvcl9pZCI6IjkxMTUyMTY2MTAyODg3ODc3NDkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | abecb2aafc6bf5281c357df662cae71bf010cc114824679036588f41028c59d9 |
| hovercard-subject-tag | issue:612895602 |
| 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/38348/issue_layout |
| twitter:image | https://opengraph.githubassets.com/31e88ad77acfb81a02adb7801eaab6a0a3bbcbd1c74b72c6c19b5c46d076867c/microsoft/TypeScript/issues/38348 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/31e88ad77acfb81a02adb7801eaab6a0a3bbcbd1c74b72c6c19b5c46d076867c/microsoft/TypeScript/issues/38348 |
| og:image:alt | TypeScript Version: Nightly Search Terms: tuple intersection array Expected behavior: Expected code to compile. It does compile with tsc 3.8, but does not compile with tsc 3.9 (Nightly). Actual beh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | NWilson |
| hostname | github.com |
| expected-hostname | github.com |
| None | 27088b6977484d0d3321d9a11c907c6d6637b315cfa359ef7952dbf6292f9b14 |
| 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 | 624179fb8b88d26ba5bba08894eb60a1c5a1d93d |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width