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

unreadable generated JS for comma-separated statements #3729

Closed
makoConstruct opened this issue Nov 18, 2014 · 4 comments
Closed

unreadable generated JS for comma-separated statements #3729

makoConstruct opened this issue Nov 18, 2014 · 4 comments
Labels

Comments

@makoConstruct
Copy link

Currently, when you assign the result of a conditional to something, the code in each block of the conditional will be generated as comma separated statements rather than semicolon separated statements. The problem is that these statements are not each given their own line. To illustrate:

a = if true
  do_things()
  do_more_things()
  generate_result()
else
  0

resolves to

a = true ? (do_things(), do_more_things(), generate_result()) : 0;

If the conditionals have a lot of content in the branches, this can make for some very unreadable generated code. It would be easier to debug our code if, instead, we got

a = true ? (
  do_things(),
  do_more_things(),
  generate_result()
) : (
  0
);
@jashkenas
Copy link
Owner

Great idea!

@MattKunze
Copy link

We use React, but use CoffeeScript instead of JSX for the render functions, and the JS emitted from those sections is less than friendly for this reason. This would help a lot to improve the readability and ease of debugging of these use cases.

@makoConstruct
Copy link
Author

Note that sourcemappings provide a better solution for debugging generated
code.

On Wed, Nov 19, 2014 at 6:50 PM, Matt Kunze notifications@github.com
wrote:

We use React, but use CoffeeScript instead of JSX for the render
functions, and the JS emitted from those sections is less than friendly for
this reason. This would help a lot to improve the readability and ease of
debugging of these use cases.


Reply to this email directly or view it on GitHub
#3729 (comment)
.

@GeoffreyBooth
Copy link
Collaborator

A PR that implements this would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants