35
35
* import { A, B } from "./b";
36
36
* export { A } from "./b";
37
37
*/
38
- import { ImportOrExportDeclaration , VisitorContext } from "../types" ;
39
38
import {
40
39
Debug ,
41
- EmitResolver ,
42
- ExportSpecifier ,
43
- ImportClause ,
44
40
ImportsNotUsedAsValues ,
45
- ImportSpecifier ,
46
41
isInJSFile ,
47
- NamedExportBindings ,
48
- NamedExports ,
49
- NamedImportBindings ,
50
- NamespaceExport ,
51
- Node ,
52
- StringLiteral ,
53
- Visitor ,
54
- VisitResult ,
42
+ type EmitResolver ,
43
+ type ExportSpecifier ,
44
+ type ImportClause ,
45
+ type ImportSpecifier ,
46
+ type NamedExportBindings ,
47
+ type NamedExports ,
48
+ type NamedImportBindings ,
49
+ type NamespaceExport ,
50
+ type Node ,
51
+ type StringLiteral ,
52
+ type Visitor ,
53
+ type VisitResult ,
55
54
} from "typescript" ;
56
55
56
+ import type { ImportOrExportDeclaration , VisitorContext } from "../types.ts" ;
57
+
57
58
/* ****************************************************************************************************************** */
58
59
// region: Utilities
59
60
/* ****************************************************************************************************************** */
@@ -104,7 +105,7 @@ export function elideImportOrExportDeclaration(
104
105
// Always elide type-only imports
105
106
if ( node . importClause . isTypeOnly ) return undefined ;
106
107
107
- const importClause = visitNode ( node . importClause , < Visitor > visitImportClause ) ;
108
+ const importClause = visitNode ( node . importClause , visitImportClause as Visitor ) ;
108
109
109
110
if (
110
111
importClause ||
@@ -139,7 +140,7 @@ export function elideImportOrExportDeclaration(
139
140
140
141
const exportClause = visitNode (
141
142
node . exportClause ,
142
- < Visitor > ( ( bindings : NamedExportBindings ) => visitNamedExportBindings ( bindings , allowEmpty ) ) ,
143
+ ( ( bindings : NamedExportBindings ) => visitNamedExportBindings ( bindings , allowEmpty ) ) as Visitor ,
143
144
isNamedExportBindings ,
144
145
) ;
145
146
@@ -171,7 +172,7 @@ export function elideImportOrExportDeclaration(
171
172
function visitImportClause ( node : ImportClause ) : VisitResult < ImportClause > {
172
173
// Elide the import clause if we elide both its name and its named bindings.
173
174
const name = shouldEmitAliasDeclaration ( node ) ? node . name : undefined ;
174
- const namedBindings = visitNode ( node . namedBindings , < Visitor > visitNamedImportBindings , isNamedImportBindings ) ;
175
+ const namedBindings = visitNode ( node . namedBindings , visitNamedImportBindings as Visitor , isNamedImportBindings ) ;
175
176
return name || namedBindings
176
177
? factory . updateImportClause ( node , /*isTypeOnly*/ false , name , namedBindings )
177
178
: undefined ;
@@ -194,7 +195,7 @@ export function elideImportOrExportDeclaration(
194
195
( compilerOptions . importsNotUsedAsValues === ImportsNotUsedAsValues . Preserve ||
195
196
compilerOptions . importsNotUsedAsValues === ImportsNotUsedAsValues . Error ) ) ;
196
197
197
- const elements = visitNodes ( node . elements , < Visitor > visitImportSpecifier , isImportSpecifier ) ;
198
+ const elements = visitNodes ( node . elements , visitImportSpecifier as Visitor , isImportSpecifier ) ;
198
199
return allowEmpty || tsInstance . some ( elements ) ? factory . updateNamedImports ( node , elements ) : undefined ;
199
200
}
200
201
}
@@ -212,7 +213,7 @@ export function elideImportOrExportDeclaration(
212
213
/** Visits named exports, eliding it if it does not contain an export specifier that resolves to a value. */
213
214
function visitNamedExports ( node : NamedExports , allowEmpty : boolean ) : VisitResult < NamedExports > | undefined {
214
215
// Elide the named exports if all of its export specifiers were elided.
215
- const elements = visitNodes ( node . elements , < Visitor > visitExportSpecifier , isExportSpecifier ) ;
216
+ const elements = visitNodes ( node . elements , visitExportSpecifier as Visitor , isExportSpecifier ) ;
216
217
return allowEmpty || tsInstance . some ( elements ) ? factory . updateNamedExports ( node , elements ) : undefined ;
217
218
}
218
219
0 commit comments