prettier / prettier

Prettier is an opinionated code formatter.
https://prettier.io
MIT License
49.22k stars 4.32k forks source link

Incorrect parenthesis removal in Angular template with pipes #14911

Open sharshuv-quotient opened 1 year ago

sharshuv-quotient commented 1 year ago

Prettier 2.8.8 Playground link

--parser angular

Input:

<accepts-boolean [value]="((a$ | async) && (b$ | async)) ?? false" />

Output:

<accepts-boolean [value]="(a$ | async) && (b$ | async) ?? false" />

Expected behavior:

The output code is incorrect. The async pipe could return null. The input code expression will always return a boolean, while the output code expression can return null. That can result in a type error build.

Could be related to https://github.com/prettier/prettier/issues/187. Even though it seems like that issue does not talk about correctness, but about readability. According to the docs - incorrect code output is always a bug.

kachkaev commented 1 year ago

Related to https://github.com/prettier/prettier/issues/5586 ?