37 lines
753 B
Markdown
37 lines
753 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 to [Biome](https://biomejs.dev/formatter/differences-with-prettier/#prettier-has-an-inconsistent-behavior-for-assignment-in-computed-keys) for bringing our attention to this inconsistency.
|
|
|
|
<!-- 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")]() {}
|
|
}
|
|
```
|