-
Notifications
You must be signed in to change notification settings - Fork 350
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
Formatting of await misses parentheses #589
Comments
seems escodegen works fine for |
This is definitely a bug, since Recast takes responsibility for inserting parentheses when necessary to preserve AST structure. There are ways to force parentheses, but that's not the recommended way of handling this. The Recast printer should just get it right. |
I opened a possible fix for this benjamn/ast-types#349 - does that seem like the right approach? |
Just hit this bug as well. The obvious workaround for those who find this is to throw a function around the await as function calls are correctly handled with awaits. |
I'm seeing a similar issue when wrapping a |
I've published a PR which should fix these and other issues with parens and also expands relevant test coverage. @skeggse I believe it improves on your PR by eliminating parens in places where they are irrelevant, e.g. |
The following two functions differ, in that one awaits the result of
a()
while one dereferencesb
off ofa
's return value and then awaits that value.The AST for the latter produces the former in
recast
:Moreover, I can't find a workaround for this bug - I'd like to explicitly wrap the
await
expression in parentheses but don't see a way to do so. EDIT: I missed theParenthesizedExpression
type.The text was updated successfully, but these errors were encountered: