mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
fix(es/lints: Handle ts export import equals (#5225)
This commit is contained in:
parent
1c2d5868ef
commit
04de455a9a
11
crates/swc/tests/errors/lints/duplicate-exports/6/.swcrc
Normal file
11
crates/swc/tests/errors/lints/duplicate-exports/6/.swcrc
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/swcrc",
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript"
|
||||
}
|
||||
},
|
||||
"module": {
|
||||
"type": "commonjs"
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
export import _ = require("lodash");
|
||||
|
||||
const lodash = _;
|
||||
|
||||
export { lodash as _ };
|
@ -0,0 +1,16 @@
|
||||
|
||||
x the name `_` is exported multiple times
|
||||
,-[1:1]
|
||||
1 | export import _ = require("lodash");
|
||||
: |
|
||||
: `-- previous exported here
|
||||
2 |
|
||||
3 | const lodash = _;
|
||||
4 |
|
||||
5 | export { lodash as _ };
|
||||
: |
|
||||
: `-- exported more than once
|
||||
`----
|
||||
|
||||
Error:
|
||||
> Exported identifiers must be unique
|
@ -136,6 +136,12 @@ impl Visit for DuplicateExports {
|
||||
};
|
||||
}
|
||||
|
||||
fn visit_ts_import_equals_decl(&mut self, n: &TsImportEqualsDecl) {
|
||||
if n.is_export && !n.is_type_only && !n.declare {
|
||||
self.add(&n.id)
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_ts_export_assignment(&mut self, n: &TsExportAssignment) {
|
||||
self.add_export_assign(n.span);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user