Skip to content

Emit destructuring patterns in 'for...in' statements for ES3/5 #2272

Closed as not planned

Description

The following is allowed by the ES6 grammar:

for (var [a, b] in []) { }

This results in a type check error, because it doesn't make sense to destructure a string key. But it should still emit correctly downlevel. Right now we emit:

for (var _a = void 0, a = _a[0], b = _a[1] in []) { }

which is incorrect.

Activity

  1. mhegazy commented on Mar 10, 2015

    @mhegazy
    Contributor

    so what is the proposed emit?

  2. JsonFreeman commented on Mar 10, 2015

    @JsonFreeman
    ContributorAuthor

    Similar to 'for...of', but 'for...in'-ified:

    for (var _a in []) {
        var a = _a[0], b = _a[1];
    }
  3. added this to the milestone on Mar 11, 2015
  4. RyanCavanaugh commented on Mar 1, 2024

    @RyanCavanaugh
    Member

    Doesn't seem like anyone has noticed this

  5. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions