mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
fix(es/lints): Ignore TS module declare blocks (#5363)
This commit is contained in:
parent
1ec9819d33
commit
daaa8b5c4a
@ -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;
|
||||
//! : ^^^^^^^^^^^
|
||||
//! `----
|
||||
|
@ -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;
|
||||
//! : ^^^^^^^^^^^
|
||||
//! `----
|
||||
|
@ -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;
|
||||
//! : ^^^^^^^^^^^
|
||||
//! `----
|
||||
|
@ -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;
|
||||
//! : ^^^^^^^^^^^
|
||||
//! `----
|
||||
|
@ -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');
|
||||
|
@ -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');
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user