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
bug in angular parser/formatter - puts brackets in wrong place which breaks the logic #5475
Comments
@ikatyang what does it mean? That the bug is in I'm sure that the code before and after Prettier behaves differently. Before prettier it applies After prettier it applies pipes only for second case of ternary. @dyatko @ryangibbsnc do you guys confirm the different behaviour? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@kirillgroshkov Since it's the official one, its behavior should be exactly the same as you compiled. The only possible issue I can think of is the version, I got the same result on both Angular 6 and 7, what version of Angular are you using? |
This comment has been minimized.
This comment has been minimized.
@ikatyang We're using Angular 7 there.
But. I'm just trying to understand your line of thought. We can both see that issue is reproducible in Prettier playground that shows |
We use the parser from Angular 6, but there should be no difference given that there's only a typo fix commit between Angular 6.1.10 (Oct 11) and 7.0.3 (Nov 8), and also I've tested it locally using Angular 7. Would you mind to run this code in your project? If the output is const ast = require("@angular/compiler").parseTemplate(`{{
(cart | async).totalPrice.amount ? 'code-accept' : 'code-accept-free'
| tmd: (cart | async)
| stripTags
}}`)
console.log(ast.nodes[0].value.ast.expressions[0].constructor.name) |
Ok, finally I understand, sorry. I tried it here and actually confirmed that you were right - that behaviour of prettier doesn't change functionality in Angular. I was wrong. https://stackblitz.com/edit/angular-playground?file=app%2Fapp.component.html I expected that this The root issue we had was actually what was fixed there: #5387 #5397 And I confirm that is not reproducible any more in 1.15.2 (but did exist in 1.15.1). Closing. Thanks a lot for clarification! Too bad it made a lot of noise for us internally because of this breakage. |
Prettier puts brackets in such place that breaks the angular pipe logic.
Prettier 1.15.2
Playground link
Input:
Output:
Expected behavior:
The text was updated successfully, but these errors were encountered: