diff --git a/crates/oxc_semantic/src/builder.rs b/crates/oxc_semantic/src/builder.rs index 35ece85937de3..6bfc2567cbab0 100644 --- a/crates/oxc_semantic/src/builder.rs +++ b/crates/oxc_semantic/src/builder.rs @@ -1675,7 +1675,8 @@ impl<'a> SemanticBuilder<'a> { func.id.is_some() } ExportDefaultDeclarationKind::ClassDeclaration(ref class) => class.id.is_some(), - _ => true, + ExportDefaultDeclarationKind::TSInterfaceDeclaration(_) => true, + _ => false, } { self.current_symbol_flags |= SymbolFlags::Export; } diff --git a/crates/oxc_semantic/tests/integration/symbols.rs b/crates/oxc_semantic/tests/integration/symbols.rs index b2c60e81a9529..2ac2613cffc6d 100644 --- a/crates/oxc_semantic/tests/integration/symbols.rs +++ b/crates/oxc_semantic/tests/integration/symbols.rs @@ -136,9 +136,30 @@ fn test_export_flag() { ", ); - tester.has_root_symbol("a").contains_flags(SymbolFlags::Export).test(); - tester.has_root_symbol("b").contains_flags(SymbolFlags::Export).test(); - tester.has_root_symbol("c").contains_flags(SymbolFlags::Export).test(); + tester.has_root_symbol("a").is_exported().test(); + tester.has_root_symbol("b").is_exported().test(); + tester.has_root_symbol("c").is_exported().test(); +} + +#[test] +fn test_export_default_flag() { + let tester = SemanticTester::ts( + " + export default function func() {} + export default class cls {} + export default interface face {} + + export default (function funcExpr() {}); + export default (function(param) {}); + ", + ); + + tester.has_root_symbol("func").is_exported().test(); + tester.has_root_symbol("cls").is_exported().test(); + tester.has_root_symbol("face").is_exported().test(); + + tester.has_symbol("funcExpr").is_not_exported().test(); + tester.has_symbol("param").is_not_exported().test(); } #[test]