fix: avoid print extra semicolon after accessor property (#4199)

## Before
```js
export default class Foo { @x @y accessor #aDef = 1 }
```
**output** 
```bash
Original:
export default class Foo { @x @y accessor #aDef = 1 }


Printed:
export default class Foo {
        accessor #aDef=1;;
}

```
This commit is contained in:
IWANABETHATGUY 2024-07-11 20:16:02 +08:00 committed by GitHub
parent e3e663bae4
commit 1c117eb20d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 2 deletions

View file

@ -2491,7 +2491,6 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for AccessorProperty<'a> {
p.print_equal();
value.gen_expr(p, Precedence::Assign, Context::default());
}
p.print_semicolon();
}
}

View file

@ -124,6 +124,14 @@ fn new_expr() {
test("new (foo()).bar();", "new (foo()).bar();\n");
}
#[test]
fn access_property() {
test(
"export default class Foo { @x @y accessor #aDef = 1 }",
"export default class Foo {\n\taccessor #aDef=1;\n}\n",
);
}
#[test]
fn for_stmt() {
test("for (let x = 0; x < 10; x++) {}", "for (let x = 0; x < 10; x++) {}\n");

View file

@ -275,7 +275,7 @@ Unexpected token
(29:11-29:15) " y =" --> (25:10-25:12) " y"
(29:15-29:26) " function()" --> (25:12-25:23) "=function()"
(29:26-29:28) " {" --> (25:23-25:24) " "
(29:28-30:1) "}\n" --> (25:24-26:0) "{};;"
(29:28-30:1) "}\n" --> (25:24-26:0) "{};"
(30:1-32:0) "}\n" --> (26:0-27:0) "\n}"
(32:0-32:4) "\nvar" --> (27:0-27:4) "\nvar"
(32:4-32:9) " aa =" --> (27:4-27:9) " aa ="