Files
test-repo/changelog_unreleased/javascript/17145.md
T

753 B

Add parentheses to AssignmentExpression in class property keys (#17145 by @fisker)

Previously we only add parentheses to AssignmentExpression in object keys, but not in class property keys. Thanks to Biome for bringing our attention to this inconsistency.

// Input
a = {
  [(x = "key")]: 1,
}

class A {
  [(x = "property")] = 1;
  [(x = "method")]() {}
}

// Prettier stable
a = {
  [(x = "key")]: 1,
};

class A {
  [x = "property"] = 1;
  [(x = "method")]() {}
}

// Prettier main
a = {
  [(x = "key")]: 1,
};

class A {
  [(x = "property")] = 1;
  [(x = "method")]() {}
}