Repository: swc-project/swc (rust)

Issue:
`globalThis` ident in decl is rewritten
### Describe the bug

`globalThis` in a const decl is rewritten to `globalThis1` (this is wrong, it should stay `globalThis`).

### Input code

```typescript
const globalThis = 0;
console.log(globalThis);
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    },
    "transform": {
      "react": {
        "importSource": "npm:react",
        "runtime": "automatic"
      }
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}
```


### Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.98-nightly-20231118.1&code=H4sIAAAAAAAAA0vOzysuUUjPyU9KzAnJyCxWsFUwsOblSgYK5%2Bek6uXkp2sgJDWtAb4aXoIvAAAA&config=H4sIAAAAAAAAA1WQPQ7CMAyFd05ReWZAHRi4AxMnsIJbBTU%2Fsh2JCvXuJOn%2FEiXfe8%2BO%2Fbs0DXzEwKP55Wt%2BRGQh3t6ZyOgVv5mAjpHEsI0K11VVKZJyokqmWQBF7klLiKS9te0SgCEEoYw7HIQW5qy33XhsaYKLTCJnY7Gi74ctf%2B7I6KUL7I6FmNDoAWRkXQysr5DYlELgo3vMtutu4uTVuqpj0uBQrYFFni7rWVuDC%2B9U%2F7RssGxpHvwOu2mdcZsHrDzXZF3f9Ae8XWptjQEAAA%3D%3D

### SWC Info output

_No response_

### Expected behavior

```js
const globalThis = 0;
console.log(globalThis);
```

### Actual behavior

```
const globalThis1 = 0;
console.log(globalThis);
```

### Version

1.3.98-nightly-20231118.1

### Additional context

_No response_

Pull request description:
fix(es/renamer): Allow `globalThis` to be shadowed
**Related issue:**

 - Closes #8317 

Patch:
diff --git a/crates/swc_ecma_transforms_base/src/resolver/mod.rs b/crates/swc_ecma_transforms_base/src/resolver/mod.rs
index 4342c7b83b..ac97304e33 100644
--- a/crates/swc_ecma_transforms_base/src/resolver/mod.rs
+++ b/crates/swc_ecma_transforms_base/src/resolver/mod.rs
@@ -304,10 +304,9 @@ impl<'a> Resolver<'a> {
                 }
 
                 return match &**sym {
-                    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects#value_properties
-                    "undefined" | "NaN" | "Infinity" | "globalThis"
-                        if mark == self.config.top_level_mark =>
-                    {
+                    // https://tc39.es/ecma262/multipage/global-object.html#sec-value-properties-of-the-global-object-infinity
+                    // non configurable global value
+                    "undefined" | "NaN" | "Infinity" if mark == self.config.top_level_mark => {
                         Some(self.config.unresolved_mark)
                     }
                     _ => Some(mark),


Test patch:
diff --git a/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/input.js b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/input.js
new file mode 100644
index 0000000000..0290601da4
--- /dev/null
+++ b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/input.js
@@ -0,0 +1,2 @@
+var globalThis = {};
+console.log(globalThis);
diff --git a/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/output.js b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/output.js
new file mode 100644
index 0000000000..91adce272a
--- /dev/null
+++ b/crates/swc_ecma_transforms_base/tests/resolver/global/globalThis/output.js
@@ -0,0 +1,2 @@
+var globalThis__2 = {};
+console.log(globalThis__2);