diff --git a/crates/oxc_ast/src/ast/js.rs b/crates/oxc_ast/src/ast/js.rs index caa3301c4..fc6cd9fef 100644 --- a/crates/oxc_ast/src/ast/js.rs +++ b/crates/oxc_ast/src/ast/js.rs @@ -2350,6 +2350,8 @@ pub struct ExportNamedDeclaration<'a> { pub source: Option>, /// `export type { foo }` pub export_kind: ImportOrExportKind, + /// Some(vec![]) for empty assertion + pub with_clause: Option>, } impl<'a> ExportNamedDeclaration<'a> { diff --git a/crates/oxc_ast/src/ast_builder.rs b/crates/oxc_ast/src/ast_builder.rs index af7880a24..ada6f0949 100644 --- a/crates/oxc_ast/src/ast_builder.rs +++ b/crates/oxc_ast/src/ast_builder.rs @@ -1120,8 +1120,16 @@ impl<'a> AstBuilder<'a> { specifiers: Vec<'a, ExportSpecifier>, source: Option>, export_kind: ImportOrExportKind, + with_clause: Option>, ) -> Box<'a, ExportNamedDeclaration<'a>> { - self.alloc(ExportNamedDeclaration { span, declaration, specifiers, source, export_kind }) + self.alloc(ExportNamedDeclaration { + span, + declaration, + specifiers, + source, + export_kind, + with_clause, + }) } /* ---------- JSX ----------------- */ diff --git a/crates/oxc_parser/src/js/module.rs b/crates/oxc_parser/src/js/module.rs index bdeb6ea19..790663f2f 100644 --- a/crates/oxc_parser/src/js/module.rs +++ b/crates/oxc_parser/src/js/module.rs @@ -234,11 +234,11 @@ impl<'a> ParserImpl<'a> { let specifiers = ExportNamedSpecifiers::parse(self)?.elements; self.ctx = ctx; - let source = if self.eat(Kind::From) && self.cur_kind().is_literal() { + let (source, with_clause) = if self.eat(Kind::From) && self.cur_kind().is_literal() { let source = self.parse_literal_string()?; - Some(source) + (Some(source), self.parse_import_attributes()?) } else { - None + (None, None) }; // ExportDeclaration : export NamedExports ; @@ -274,7 +274,14 @@ impl<'a> ParserImpl<'a> { self.asi()?; let span = self.end_span(span); - Ok(self.ast.export_named_declaration(span, None, specifiers, source, export_kind)) + Ok(self.ast.export_named_declaration( + span, + None, + specifiers, + source, + export_kind, + with_clause, + )) } // export Declaration @@ -300,6 +307,7 @@ impl<'a> ParserImpl<'a> { self.ast.new_vec(), None, ImportOrExportKind::Value, + None, )) } diff --git a/crates/oxc_transformer/src/proposals/decorators.rs b/crates/oxc_transformer/src/proposals/decorators.rs index ffc56c895..44b2a1740 100644 --- a/crates/oxc_transformer/src/proposals/decorators.rs +++ b/crates/oxc_transformer/src/proposals/decorators.rs @@ -230,6 +230,7 @@ impl<'a> Decorators<'a> { )), None, ImportOrExportKind::Value, + None, ), ), )); @@ -283,6 +284,7 @@ impl<'a> Decorators<'a> { )), None, ImportOrExportKind::Value, + None, ), ), )); diff --git a/crates/oxc_transformer/src/typescript/mod.rs b/crates/oxc_transformer/src/typescript/mod.rs index b3e95e4f3..bea7a40da 100644 --- a/crates/oxc_transformer/src/typescript/mod.rs +++ b/crates/oxc_transformer/src/typescript/mod.rs @@ -243,6 +243,7 @@ impl<'a> TypeScript<'a> { self.ast.new_vec(), None, ImportOrExportKind::Value, + None, ); let export_decl = ModuleDeclaration::ExportNamedDeclaration(empty_export); program.body.push(self.ast.module_declaration(export_decl)); @@ -625,6 +626,7 @@ impl<'a> TypeScript<'a> { self.ast.new_vec(), None, ImportOrExportKind::Value, + None, ), )) } else {