Title: Destructuring an array into incompatible type no longer throws an error · Issue #14768 · microsoft/TypeScript · GitHub
Open Graph Title: Destructuring an array into incompatible type no longer throws an error · Issue #14768 · microsoft/TypeScript
X Title: Destructuring an array into incompatible type no longer throws an error · Issue #14768 · microsoft/TypeScript
Description: TypeScript Version: 2.2.1 / 2.1.4 Code let foo: Array
Open Graph Description: TypeScript Version: 2.2.1 / 2.1.4 Code let foo: Array
X Description: TypeScript Version: 2.2.1 / 2.1.4 Code let foo: Array<number> = [1, 2, 3, 4]; let bar: Array<number> = { ...foo }; When I try to compile with tsc@2.1.4, I get the following error: error...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/14768
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Destructuring an array into incompatible type no longer throws an error","articleBody":"\u003c!-- BUGS: Please use this template. --\u003e\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript --\u003e\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md --\u003e\r\n\r\n**TypeScript Version:** 2.2.1 / 2.1.4\r\n\r\n**Code**\r\n\r\n```ts\r\nlet foo: Array\u003cnumber\u003e = [1, 2, 3, 4];\r\nlet bar: Array\u003cnumber\u003e = { ...foo };\r\n```\r\n\r\nWhen I try to compile with `tsc@2.1.4`, I get the following error:\r\n\r\n\u003e error TS2322: Type '{ [n: number]: number; length: number; }' is not assignable to type 'number[]'.\r\n\u003e Property 'push' is missing in type '{ [n: number]: number; length: number; }'.\r\n\r\nWith `tsc@2.2.1` I no longer get an error. This should not compile as `bar` is not of type `Array\u003cnumber\u003e`.\r\n","author":{"url":"https://github.com/saravanaj","@type":"Person","name":"saravanaj"},"datePublished":"2017-03-21T16:46:18.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/14768/TypeScript/issues/14768"}
| 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:5cb5497f-78b5-c90c-e386-fc60fd31e914 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EA46:2AD179:8322EC:B2C380:6A6283CE |
| html-safe-nonce | 72b31a37b6ab9a96e32cf4771058ef62a4960af9d6dd0a1593d6ec10cd502112 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQTQ2OjJBRDE3OTo4MzIyRUM6QjJDMzgwOjZBNjI4M0NFIiwidmlzaXRvcl9pZCI6IjgzNjA2ODQxMDAxMTEyMDUzMjYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 7d47a73f1df84b6513e8115f7a6133f5398f29b4772d6101c9d3998680e242df |
| hovercard-subject-tag | issue:215805538 |
| 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/14768/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2594fa9e5da719adbab5ef75d0273d4d989786f325949b974135b86da7d55a88/microsoft/TypeScript/issues/14768 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2594fa9e5da719adbab5ef75d0273d4d989786f325949b974135b86da7d55a88/microsoft/TypeScript/issues/14768 |
| og:image:alt | TypeScript Version: 2.2.1 / 2.1.4 Code let foo: Array |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | saravanaj |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7a4ef49a11a2c05de16a801b29c54a151d2e3262d6fd17381ca13b5ae25dda8f |
| 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 | 97b18c8f1d2683a31995fd6e802daf9bf0d4d3f0 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width