Files
test-repo/changelog_unreleased/javascript/15468.md
T
2023-09-28 14:56:55 +08:00

640 B

Disambiguate unary expressions on left hand side of instanceof and in (#15468 by @lucacasonato)

Parentheses are now added around unary expression on the left hand side of instanceof and in expressions, to disambiguate the unary on the left hand side with a unary applying to the entire binary expression.

This helps catch a common mistake where a user intends to write !("x" in y) but instead writes !"x" in y, which is really parsed as the nonsensical (!"x") in y.

// Input
!"x" in y;
!("x" in y);

// Prettier stable
!"x" in y;
!("x" in y);

// Prettier main
(!"x") in y;
!("x" in y);