Prettier v3.8.1
Playground link
--parser babel
--tab-width 4
--no-semi
--experimental-ternaries
Input:
let o = 1;
(
1 ||
12345678901234567890123456789012345678901234567890123456789012345678901234567890
) ?
2
: 3
Output:
let o = 1
(
1 ||
12345678901234567890123456789012345678901234567890123456789012345678901234567890
) ?
2
: 3
Expected output:
let o = 1
;(
1 ||
12345678901234567890123456789012345678901234567890123456789012345678901234567890
) ?
2
: 3
Why?
The output Prettier gives visibly changes the program, so that it tries to call 1 as a function, instead of assigning it to o. I expect that Prettier should maintain the runtime behavior of the code by inserting a semicolon before the parenthesized ternary condition.
Prettier v3.8.1
Playground link
Input:
Output:
Expected output:
Why?
The output Prettier gives visibly changes the program, so that it tries to call
1as a function, instead of assigning it too. I expect that Prettier should maintain the runtime behavior of the code by inserting a semicolon before the parenthesized ternary condition.