-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Allow keeping parenthesis for closure compiler type casting #1445
Comments
We're not doing a good job at respecting all those comments. We also have a bunch of issues with flow comments. |
@vjeux It's not just that the comment is moved; Closure is treating the parentheses as semantic, and will give a warning if they're dropped. (Ugh.) |
* Handle closure compiler type cast syntax correctly Fixes #1445 * Move closure type cast detection to needParens in fast-path.js * every => some and added additional check for leading comment
Thanks a bunch for addressing this, I found one oversight though.
prettier outputs
The workaround is easy though: just move the cast to a different statement, like this:
or add additional parentheses:
|
This doesn't seem to work for me. It should work without setting a specific option, right? a.) Gets rewritten to b.) And if I do this c.) It gets rewritten to a. on the first save and eventually to b. on the second save. I'm using the 'Prettier - Code formatter' extension for VS Code. |
@roelkok That sounds like a bug. Can you open a new issue and fill out the template please? |
Opened an new issue here #4124 |
When writing javascript for use with the Closure compiler, parenthesis directly following a type annotation comment have meaning.
Type cast precede a parenthesized expression.
prettier outputs:
The text was updated successfully, but these errors were encountered: