Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Destructuring an array into incompatible type no longer throws an error #14768

Closed
saravanaj opened this issue Mar 21, 2017 · 1 comment
Closed
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@saravanaj
Copy link

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 TS2322: Type '{ [n: number]: number; length: number; }' is not assignable to type 'number[]'.
Property 'push' is missing in type '{ [n: number]: number; length: number; }'.

With tsc@2.2.1 I no longer get an error. This should not compile as bar is not of type Array<number>.

@RyanCavanaugh RyanCavanaugh added the Bug A bug in TypeScript label Mar 21, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Feb 8, 2018

Should be fixed in latest.

@mhegazy mhegazy closed this as completed Feb 8, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 8, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants