Skip to content

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

Closed
@saravanaj

Description

@saravanaj

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 [email protected], 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 [email protected] I no longer get an error. This should not compile as bar is not of type Array<number>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions