mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(ast): parse with_clause in re-export declaration (#2634)
This commit is contained in:
parent
17bc711bf0
commit
2a235d3b8c
5 changed files with 27 additions and 5 deletions
|
|
@ -2350,6 +2350,8 @@ pub struct ExportNamedDeclaration<'a> {
|
|||
pub source: Option<StringLiteral<'a>>,
|
||||
/// `export type { foo }`
|
||||
pub export_kind: ImportOrExportKind,
|
||||
/// Some(vec![]) for empty assertion
|
||||
pub with_clause: Option<WithClause<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> ExportNamedDeclaration<'a> {
|
||||
|
|
|
|||
|
|
@ -1120,8 +1120,16 @@ impl<'a> AstBuilder<'a> {
|
|||
specifiers: Vec<'a, ExportSpecifier>,
|
||||
source: Option<StringLiteral<'a>>,
|
||||
export_kind: ImportOrExportKind,
|
||||
with_clause: Option<WithClause<'a>>,
|
||||
) -> 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 ----------------- */
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ impl<'a> Decorators<'a> {
|
|||
)),
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
None,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
|
@ -283,6 +284,7 @@ impl<'a> Decorators<'a> {
|
|||
)),
|
||||
None,
|
||||
ImportOrExportKind::Value,
|
||||
None,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue