Skip to content
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

TypeError processing for...of with variable declaration #181

Closed
ongardie opened this issue Nov 11, 2015 · 2 comments
Closed

TypeError processing for...of with variable declaration #181

ongardie opened this issue Nov 11, 2015 · 2 comments

Comments

@ongardie
Copy link

Here's an example:

$ cat test.js
"use strict";
let x = [4, 3, 2];
for (var v of x) {
  console.log(v);
}
$ node test.js 
4
3
2
$ node ./node_modules/jsfmt/bin/jsfmt test.js
test.js [TypeError: varDeclarationParentBody.indexOf is not a function]
$ node ./node_modules/jsfmt/bin/jsfmt --version
jsfmt 0.5.2
@brettlangdon
Copy link
Contributor

@ongardie thank you for reporting!

Fun hint, you can do just ./node_modules/.bin/jsfmt.

Yeah, there are some ES6 features which are not fully supported by esformatter or esprima, which is what we are using for parsing/formatting of code in jsfmt.

I started to compile a list of working ES6 examples and code which is not yet supported in #175, need to try and finish that at some point.

@ongardie
Copy link
Author

@brettlangdon: ah, feel free to close if this is a duplicate of #175.

BTW, I've actually had pretty good luck with ES6 features so far. This is the first snag I've run into, and it's not a major one.

ongardie-sfdc pushed a commit to salesforce/runway-compiler that referenced this issue Apr 30, 2016
Now crashes on `for (var x of y)` rather than outputting the wrong thing.
Work around it with `var x; for (x of y)`.
rdio/jsfmt#181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants