fix: no semi for readonly class field (#16133)

Co-authored-by: Sosuke Suzuki <sosuke.suzuki@dr-ubie.com>
This commit is contained in:
三咲智子 Kevin DengandSosuke Suzuki authored and GitHub committed 2024-03-09 20:46:47 +09:00
1 parent a28164eb93
commit 765aa10dfe
4 files changed
+29 -1

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
#### Respect `--no-semi` for readonly class field (#16133 by @sxzz)
<!-- prettier-ignore -->
```tsx
// Input
class A {
field
readonly [expr] = true
}
// Prettier stable
class A {
field;
readonly [expr] = true
}
// Prettier main
class A {
field
readonly [expr] = true
}
```
+2 -1
View File
@@ -323,7 +323,8 @@ function shouldPrintSemicolonAfterClassProperty(node, nextNode) {
if (
nextNode.static ||
nextNode.accessibility // TypeScript
nextNode.accessibility || // TypeScript
nextNode.readonly // TypeScript
) {
return false;
}
@@ -16,6 +16,7 @@ class A {
bar: A;
private [baz]
readonly [qux]
}
=====================================output=====================================
@@ -28,6 +29,7 @@ class A {
bar: A
private [baz]
readonly [qux]
}
================================================================================
@@ -48,6 +50,7 @@ class A {
bar: A;
private [baz]
readonly [qux]
}
=====================================output=====================================
@@ -60,6 +63,7 @@ class A {
bar: A;
private [baz];
readonly [qux];
}
================================================================================
@@ -7,4 +7,5 @@ class A {
bar: A;
private [baz]
readonly [qux]
}