Repository: swc-project/swc (rust)

Issue:
1++ should be an error
### Describe the bug

If parser is set to js, swc would report error but in ts it won't

### Input code

```typescript
1++
```


### Config

_No response_

### Playground link

_No response_

### Expected behavior

Should be error

### Actual behavior

_No response_

### Version

1.2.150

### Additional context

_No response_

Pull request description:
fix-3885 report error if LeftHandSideExpression is invalid
<!-- Note: CI script will automatically rebase your PR so please do not rebase unless required -->

<!-- Thanks for submitting a pull request! Please provide enough information so that others can review your pull request. -->

**Description:**
fixes #3885
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

**BREAKING CHANGE:**
None
<!--
If this PR introduces a breaking change, it must contain a notice for it to be included in the CHANGELOG. Add description or remove entirely if not breaking.

You may need to update `MIGRATION.md` for the breaking changes.
-->

**Related issue (if exists):**
#3885

Patch:
diff --git a/crates/swc_ecma_parser/src/parser/expr.rs b/crates/swc_ecma_parser/src/parser/expr.rs
index c5755a7214..410e16583d 100644
--- a/crates/swc_ecma_parser/src/parser/expr.rs
+++ b/crates/swc_ecma_parser/src/parser/expr.rs
@@ -1901,6 +1901,10 @@ impl<'a, I: Tokens> Parser<I> {
     }
 
     pub(super) fn check_assign_target(&mut self, expr: &Expr, deny_call: bool) {
+        if !expr.is_valid_simple_assignment_target(self.ctx().strict) {
+            self.emit_err(expr.span(), SyntaxError::TS2406);
+        }
+
         // We follow behavior of tsc
         if self.input.syntax().typescript() && self.syntax().early_errors() {
             let is_eval_or_arguments = match *expr {
@@ -1932,8 +1936,6 @@ impl<'a, I: Tokens> Parser<I> {
             {
                 self.emit_err(expr.span(), SyntaxError::TS2406);
             }
-        } else if !expr.is_valid_simple_assignment_target(self.ctx().strict) {
-            self.emit_err(expr.span(), SyntaxError::TS2406);
         }
     }
 }


Test patch:
diff --git a/crates/swc_ecma_parser/tests/typescript-errors/issue-3885/input.ts b/crates/swc_ecma_parser/tests/typescript-errors/issue-3885/input.ts
new file mode 100644
index 0000000000..f85efba66e
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript-errors/issue-3885/input.ts
@@ -0,0 +1,1 @@
+1++;
diff --git a/crates/swc_ecma_parser/tests/typescript-errors/issue-3885/input.ts.stderr b/crates/swc_ecma_parser/tests/typescript-errors/issue-3885/input.ts.stderr
new file mode 100644
index 0000000000..2cf6270cd6
--- /dev/null
+++ b/crates/swc_ecma_parser/tests/typescript-errors/issue-3885/input.ts.stderr
@@ -0,0 +1,6 @@
+
+  x The left-hand side of an assignment expression must be a variable or a property access.
+   ,-[$DIR/tests/typescript-errors/issue-3885/input.ts:2:1]
+ 2 | 1++;
+   : ^
+   `----