Skip to content

Destructuring array into an object is assignable to an array type #34780

Closed
@strawberry-choco

Description

@strawberry-choco

TypeScript Version: 3.8.0-dev.20191026

Search Terms:

  • array destructuring object
  • array destructure assign

Code

let bar = [1, 2, 3]

let foo: any[] = { ...bar }

console.log(Array.isArray(foo)) // false

Expected behavior: Typescript errors about type mismatch.

Actual behavior: Typescript does neither warn nor error about this and foo is no longer an array.

Playground Link: https://www.typescriptlang.org/play/?ts=3.8.0-dev.20191026&ssl=1&ssc=18&pln=1&pc=8#code/DYUwLgBARghgThAvBA2gRgDQQExYMwC6AUEaJAGYD2lAXBDAHYCeKBSEA3hAHS+wIBfEgGNKDAM6VQ3YJQDmACgCCcODCbcAluJVqmCqpQCURiAHozEcjGDiQQA

Related Issues: #14768

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions