From 756a57143214d39b7e18f23c5df804874035c4b0 Mon Sep 17 00:00:00 2001 From: Dunqing <29533304+Dunqing@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:19:02 +0000 Subject: [PATCH] fix(isolated-declarations): missing empty export when has an export declare (#5925) --- crates/oxc_isolated_declarations/src/lib.rs | 2 +- .../oxc_isolated_declarations/tests/fixtures/empty-export.ts | 4 ++++ .../tests/snapshots/empty-export.snap | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/oxc_isolated_declarations/src/lib.rs b/crates/oxc_isolated_declarations/src/lib.rs index 64eb2fac8e2ed..fd9ca24b210e9 100644 --- a/crates/oxc_isolated_declarations/src/lib.rs +++ b/crates/oxc_isolated_declarations/src/lib.rs @@ -253,7 +253,7 @@ impl<'a> IsolatedDeclarations<'a> { transformed_spans.insert(decl.span); if let Some(new_decl) = self.transform_export_named_declaration(decl) { *decl = self.ast.alloc(new_decl); - } else { + } else if decl.declaration.is_none() { need_empty_export_marker = false; } self.scope.visit_export_named_declaration(decl); diff --git a/crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts b/crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts index 0b8a0adab3bcf..9087a1aeaf53a 100644 --- a/crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts +++ b/crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts @@ -2,3 +2,7 @@ type A = string; export function a(): A { return "" } + +export declare const ShallowReactiveMarker: unique symbol + +export type ShallowReactive = T & { [ShallowReactiveMarker]?: true } diff --git a/crates/oxc_isolated_declarations/tests/snapshots/empty-export.snap b/crates/oxc_isolated_declarations/tests/snapshots/empty-export.snap index bea8f064efdf0..ab5a889193908 100644 --- a/crates/oxc_isolated_declarations/tests/snapshots/empty-export.snap +++ b/crates/oxc_isolated_declarations/tests/snapshots/empty-export.snap @@ -6,4 +6,6 @@ input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts type A = string; export declare function a(): A; +export declare const ShallowReactiveMarker: unique symbol; +export type ShallowReactive = T & { [ShallowReactiveMarker]?: true }; export {};