fix(es/lints): Ignore TS module declare blocks (#5363)

This commit is contained in:
magic-akari 2022-08-02 14:16:30 +08:00 committed by GitHub
parent 1ec9819d33
commit daaa8b5c4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 6 additions and 148 deletions

View File

@ -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;
//! : ^^^^^^^^^^^
//! `----

View File

@ -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;
//! : ^^^^^^^^^^^
//! `----

View File

@ -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;
//! : ^^^^^^^^^^^
//! `----

View File

@ -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;
//! : ^^^^^^^^^^^
//! `----

View File

@ -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');

View File

@ -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');

View File

@ -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");

View File

@ -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;

View File

@ -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,