Skip to content

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

New issue

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

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

Already on GitHub? Sign in to your account

Closed
JsonFreeman opened this issue Mar 9, 2015 · 3 comments
Closed

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

JsonFreeman opened this issue Mar 9, 2015 · 3 comments
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@JsonFreeman
Copy link
Contributor

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.

@JsonFreeman JsonFreeman added the Bug A bug in TypeScript label Mar 9, 2015
@mhegazy
Copy link
Contributor

mhegazy commented Mar 10, 2015

so what is the proposed emit?

@JsonFreeman
Copy link
Contributor Author

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

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

@mhegazy mhegazy added the Help Wanted You can do this label Mar 11, 2015
@mhegazy mhegazy added this to the Community milestone Mar 11, 2015
@RyanCavanaugh RyanCavanaugh modified the milestones: Community, Backlog Mar 7, 2019
@RyanCavanaugh
Copy link
Member

Doesn't seem like anyone has noticed this

@RyanCavanaugh RyanCavanaugh closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants