Skip to content

Commit 0befbe5

Browse files
committed
fix: Certain edge cases existed where type elision improperly elided full import / export declarations without named bindings (closes #87)
1 parent 47f9d64 commit 0befbe5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/visitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function nodeVisitor(this: VisitorContext, node: ts.Node): ts.Node | unde
109109
return resolvePathAndUpdateNode(this, node, node.moduleSpecifier.text, (p) => {
110110
let importClause = node.importClause;
111111

112-
if (!this.isDeclarationFile && importClause) {
112+
if (!this.isDeclarationFile && importClause?.namedBindings) {
113113
const updatedImportClause = elideImportOrExportClause(this, node);
114114
if (!updatedImportClause) return undefined; // No imports left, elide entire declaration
115115
importClause = updatedImportClause;
@@ -127,7 +127,7 @@ export function nodeVisitor(this: VisitorContext, node: ts.Node): ts.Node | unde
127127
return resolvePathAndUpdateNode(this, node, node.moduleSpecifier.text, (p) => {
128128
let exportClause = node.exportClause;
129129

130-
if (!this.isDeclarationFile && exportClause) {
130+
if (!this.isDeclarationFile && exportClause && tsInstance.isNamedExports(exportClause)) {
131131
const updatedExportClause = elideImportOrExportClause(this, node);
132132
if (!updatedExportClause) return undefined; // No export left, elide entire declaration
133133
exportClause = updatedExportClause;

0 commit comments

Comments
 (0)