Title: Overly strict type narrowing in tuple · Issue #27557 · microsoft/TypeScript · GitHub
Open Graph Title: Overly strict type narrowing in tuple · Issue #27557 · microsoft/TypeScript
X Title: Overly strict type narrowing in tuple · Issue #27557 · microsoft/TypeScript
Description: TypeScript Version: 3.2.0-dev.201xxxxx Search Terms: type narrowing tuple type inference tuple Code const x: [number, number] = [0, 0]; if (x[0] === 0) { x[0] = -1; } Expected behavior: The code should compile. The above code does compil...
Open Graph Description: TypeScript Version: 3.2.0-dev.201xxxxx Search Terms: type narrowing tuple type inference tuple Code const x: [number, number] = [0, 0]; if (x[0] === 0) { x[0] = -1; } Expected behavior: The code sh...
X Description: TypeScript Version: 3.2.0-dev.201xxxxx Search Terms: type narrowing tuple type inference tuple Code const x: [number, number] = [0, 0]; if (x[0] === 0) { x[0] = -1; } Expected behavior: The code sh...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/27557
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Overly strict type narrowing in tuple","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker. Even if you think you've found a *bug*, please read the FAQ first, especially the Common \"Bugs\" That Aren't Bugs section!\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\nPlease fill in the *entire* template below.\r\n-->\r\n\r\n\u003c!-- Please try to reproduce the issue with `typescript@next`. It may have already been fixed. -->\r\n**TypeScript Version:** 3.2.0-dev.201xxxxx\r\n\r\n\u003c!-- Search terms you tried before logging this (so others can find this issue more easily) -->\r\n**Search Terms:**\r\ntype narrowing tuple\r\ntype inference tuple\r\n\r\n**Code**\r\n\r\n```ts\r\nconst x: [number, number] = [0, 0];\r\nif (x[0] === 0) {\r\n x[0] = -1;\r\n}\r\n```\r\n\r\n**Expected behavior:**\r\nThe code should compile. The above code does compile with `typescript@3.0.3`.\r\n\r\n**Actual behavior:**\r\n\r\nerror TS2322: Type '-1' is not assignable to type '0'.\r\n\r\n**Playground Link:** http://www.typescriptlang.org/play/\r\n\r\n**Related Issues:** \u003c!-- Did you find other bugs that looked similar? -->\r\n","author":{"url":"https://github.com/westonpace","@type":"Person","name":"westonpace"},"datePublished":"2018-10-04T20:47:56Z","url":"https://github.com/microsoft/TypeScript/issues/27557"}
| 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:a3dfbdae-f947-ace3-fea3-9d8739190147 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A562:2B4064:1AB78E:24F068:6B0466BD |
| html-safe-nonce | 0a91c3513307cc9e3f02e3a302f82dd1b72ee641608faeb6047874ed93f5dde2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTYyOjJCNDA2NDoxQUI3OEU6MjRGMDY4OjZCMDQ2NkJEIiwidmlzaXRvcl9pZCI6IjU1MTA1MjMxMzUxMTM1ODYzNjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f3a1f93313079e1229b1f49d3621aa839f18fd2ce608e2a704f5ed887471be35 |
| hovercard-subject-tag | issue:366964029 |
| 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/27557/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf7c7d4d5e97133c2878291174fdadeaee0e8aaec39704b59ef88d6dad6f9375/microsoft/TypeScript/issues/27557 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf7c7d4d5e97133c2878291174fdadeaee0e8aaec39704b59ef88d6dad6f9375/microsoft/TypeScript/issues/27557 |
| og:image:alt | TypeScript Version: 3.2.0-dev.201xxxxx Search Terms: type narrowing tuple type inference tuple Code const x: [number, number] = [0, 0]; if (x[0] === 0) { x[0] = -1; } Expected behavior: The code sh... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | westonpace |
| hostname | github.com |
| expected-hostname | github.com |
| None | 83e4c0e58c5162177f3c161c5fbad38527ae04c11ac14980f9f9d85ae2027b1f |
| 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 | ca4d07a7cef4e4b75f821dc25e7300d80c1450a9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width