Repository: swc-project/swc (rust)

Issue:
`the name default is exported multiple times` in global declaration file
### Describe the bug

in global declaration file, where declare multiple modules

### Input code

```typescript
declare module 'a' {
    const Component: any;
    export default Component;
}

declare module 'b' {
    const Component: any;
    export default Component;
}
```


### Config

```json
{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es5",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}
```


### Playground link

https://play.swc.rs/?version=1.2.222&code=H4sIAAAAAAAAA0tJTc5JLEpVyM1PKc1JVVBPVFeo5lIAguT8vOISBef83IL8vNS8EiuFxLxKa7BMakVBflGJQkpqWmJpDpISa65aLq4UNPOSKDIPADGKN8ueAAAA&config=H4sIAAAAAAAAA0WNSwrDMAxE76J1ts0id%2BghjKsEF%2F%2FQKBBjfPfawSU7aebpqdIXlrZK2QhYxoQS1Vy0kZbMsOKy0kKKHu3Gg1tfjBysHWG8eudTAs92oeCi28sw2RSyMPBUJh7%2BT7YuCulzjqDez27hSu1xzDuH9wRVTm4%2FOkwQUrUAAAA%3D

### Expected behavior

no error report

### Actual behavior

```bash

  x the name `default` is exported multiple times
   ,-[input.ts:3:5]
 3 | export default Component;
   : ^^^^^^^^^^^^|^^^^^^^^^^^^
   :             `-- previous exported here
 4 | }
 5 | 
 6 | declare module 'b' {
 7 |     const Component: any;
 8 |     export default Component;
   :     ^^^^^^^^^^^^|^^^^^^^^^^^^
   :                 `-- exported more than once
   `----

Error: 
  > Exported identifiers must be unique
```

### Version

1.2.222

### Additional context

_No response_

Pull request description:
fix(es/lint): Ignore TS module declare block
<!-- 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:**

<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->

**BREAKING CHANGE:**

<!--
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):**
- fix #5362

Patch:
diff --git a/crates/swc_ecma_lints/src/rules/duplicate_exports.rs b/crates/swc_ecma_lints/src/rules/duplicate_exports.rs
index 8e0e70d2dc..05398e9734 100644
--- a/crates/swc_ecma_lints/src/rules/duplicate_exports.rs
+++ b/crates/swc_ecma_lints/src/rules/duplicate_exports.rs
@@ -80,6 +80,12 @@ impl DuplicateExports {
 impl Visit for DuplicateExports {
     noop_visit_type!();
 
+    fn visit_ts_module_decl(&mut self, d: &TsModuleDecl) {
+        if !d.declare {
+            d.visit_children_with(self);
+        }
+    }
+
     fn visit_export_default_decl(&mut self, d: &ExportDefaultDecl) {
         if matches!(
             d.decl,


Test patch:
diff --git a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.1.normal.js
index 57b07db168..5d14cc6b07 100644
--- a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.1.normal.js
+++ b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.1.normal.js
@@ -6,23 +6,3 @@
 import a from "a";
 a();
 // @filename: external.d.ts
-//!
-//!  x the name `default` is exported multiple times
-//!   ,-[6:9]
-//! 6 | export { _a as default };
-//!   :                ^^^|^^^
-//!   :                   `-- previous exported here
-//! 7 |     }
-//! 8 |     export default a;
-//!   :     ^^^^^^^^|^^^^^^^^
-//!   :             `-- exported more than once
-//!   `----
-//!
-//!Error: 
-//!  > Exported identifiers must be unique
-//!
-//!  x An export assignment cannot be used in a module with other exported elements.
-//!    ,----
-//! 13 | export = a;
-//!    : ^^^^^^^^^^^
-//!    `----
diff --git a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.2.minified.js
index 654e2b48b8..72798234eb 100644
--- a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.2.minified.js
+++ b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es2015.2.minified.js
@@ -1,23 +1,2 @@
 import a from "a";
 a();
-// @filename: external.d.ts
-//!
-//!  x the name `default` is exported multiple times
-//!   ,-[6:9]
-//! 6 | export { _a as default };
-//!   :                ^^^|^^^
-//!   :                   `-- previous exported here
-//! 7 |     }
-//! 8 |     export default a;
-//!   :     ^^^^^^^^|^^^^^^^^
-//!   :             `-- exported more than once
-//!   `----
-//!
-//!Error: 
-//!  > Exported identifiers must be unique
-//!
-//!  x An export assignment cannot be used in a module with other exported elements.
-//!    ,----
-//! 13 | export = a;
-//!    : ^^^^^^^^^^^
-//!    `----
diff --git a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.1.normal.js b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.1.normal.js
index 57b07db168..5d14cc6b07 100644
--- a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.1.normal.js
+++ b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.1.normal.js
@@ -6,23 +6,3 @@
 import a from "a";
 a();
 // @filename: external.d.ts
-//!
-//!  x the name `default` is exported multiple times
-//!   ,-[6:9]
-//! 6 | export { _a as default };
-//!   :                ^^^|^^^
-//!   :                   `-- previous exported here
-//! 7 |     }
-//! 8 |     export default a;
-//!   :     ^^^^^^^^|^^^^^^^^
-//!   :             `-- exported more than once
-//!   `----
-//!
-//!Error: 
-//!  > Exported identifiers must be unique
-//!
-//!  x An export assignment cannot be used in a module with other exported elements.
-//!    ,----
-//! 13 | export = a;
-//!    : ^^^^^^^^^^^
-//!    `----
diff --git a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.2.minified.js b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.2.minified.js
index 654e2b48b8..72798234eb 100644
--- a/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.2.minified.js
+++ b/crates/swc/tests/tsc-references/exportAssignmentOfExportNamespaceWithDefault_es5.2.minified.js
@@ -1,23 +1,2 @@
 import a from "a";
 a();
-// @filename: external.d.ts
-//!
-//!  x the name `default` is exported multiple times
-//!   ,-[6:9]
-//! 6 | export { _a as default };
-//!   :                ^^^|^^^
-//!   :                   `-- previous exported here
-//! 7 |     }
-//! 8 |     export default a;
-//!   :     ^^^^^^^^|^^^^^^^^
-//!   :             `-- exported more than once
-//!   `----
-//!
-//!Error: 
-//!  > Exported identifiers must be unique
-//!
-//!  x An export assignment cannot be used in a module with other exported elements.
-//!    ,----
-//! 13 | export = a;
-//!    : ^^^^^^^^^^^
-//!    `----
diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.1.normal.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.1.normal.js
index 4641eb3602..79d739a1ad 100644
--- a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.1.normal.js
+++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.1.normal.js
@@ -2,22 +2,6 @@
 //@jsx: preserve
 //@target: ES5
 //@Filename: react.d.ts
-//!
-//!  x multiple `export =` found
-//!    ,-[4:5]
-//!  4 | export = x;
-//!    : ^^^^^|^^^^^
-//!    :      `-- previous `export =` declared here
-//!  5 | }
-//!  6 | 
-//!  7 | declare module ReactRouter {
-//!  8 | 	var Route: any;
-//!  9 | 	interface Thing { }
-//! 10 | }
-//! 11 | declare module 'react-router' {
-//! 12 | 	export = ReactRouter;
-//!    :  ^^^^^^^^^^^^^^^^^^^^^
-//!    `----
 //@Filename: test.tsx
 // Should emit 'react-router' in the AMD dependency list
 const React = require('react');
diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.2.minified.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.2.minified.js
index 4d2d550fb8..b70b42ee25 100644
--- a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.2.minified.js
+++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es2015.2.minified.js
@@ -1,20 +1,3 @@
-//@Filename: react.d.ts
-//!
-//!  x multiple `export =` found
-//!    ,-[4:5]
-//!  4 | export = x;
-//!    : ^^^^^|^^^^^
-//!    :      `-- previous `export =` declared here
-//!  5 | }
-//!  6 | 
-//!  7 | declare module ReactRouter {
-//!  8 | 	var Route: any;
-//!  9 | 	interface Thing { }
-//! 10 | }
-//! 11 | declare module 'react-router' {
-//! 12 | 	export = ReactRouter;
-//!    :  ^^^^^^^^^^^^^^^^^^^^^
-//!    `----
 var M;
 require('react');
 let ReactRouter = require('react-router');
diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.1.normal.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.1.normal.js
index e18a57e7e5..f9b5d970d3 100644
--- a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.1.normal.js
+++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.1.normal.js
@@ -2,22 +2,6 @@
 //@jsx: preserve
 //@target: ES5
 //@Filename: react.d.ts
-//!
-//!  x multiple `export =` found
-//!    ,-[4:5]
-//!  4 | export = x;
-//!    : ^^^^^|^^^^^
-//!    :      `-- previous `export =` declared here
-//!  5 | }
-//!  6 | 
-//!  7 | declare module ReactRouter {
-//!  8 | 	var Route: any;
-//!  9 | 	interface Thing { }
-//! 10 | }
-//! 11 | declare module 'react-router' {
-//! 12 | 	export = ReactRouter;
-//!    :  ^^^^^^^^^^^^^^^^^^^^^
-//!    `----
 //@Filename: test.tsx
 // Should emit 'react-router' in the AMD dependency list
 var React = require("react");
diff --git a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.2.minified.js b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.2.minified.js
index c39fba2393..760789b17a 100644
--- a/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.2.minified.js
+++ b/crates/swc/tests/tsc-references/tsxPreserveEmit1_es5.2.minified.js
@@ -1,20 +1,3 @@
-//@Filename: react.d.ts
-//!
-//!  x multiple `export =` found
-//!    ,-[4:5]
-//!  4 | export = x;
-//!    : ^^^^^|^^^^^
-//!    :      `-- previous `export =` declared here
-//!  5 | }
-//!  6 | 
-//!  7 | declare module ReactRouter {
-//!  8 | 	var Route: any;
-//!  9 | 	interface Thing { }
-//! 10 | }
-//! 11 | declare module 'react-router' {
-//! 12 | 	export = ReactRouter;
-//!    :  ^^^^^^^^^^^^^^^^^^^^^
-//!    `----
 var M;
 require("react"), require("react-router").Route, function(M) {
     var X1;