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

37 lines
749 B
Markdown

#### 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 for [Biome](https://biomejs.dev/formatter/differences-with-prettier/#prettier-has-an-inconsistent-behavior-for-assignment-in-computed-keys) to bring our attention on this inconsistent.
<!-- prettier-ignore -->
```jsx
// 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")]() {}
}
```