feat(prettier): print with_clause in reexport declaration (#2635)

This commit is contained in:
magic-akari 2024-03-07 14:24:16 +08:00 committed by GitHub
parent 2a235d3b8c
commit 8e3e4043bc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 11 deletions

View file

@ -2216,6 +2216,17 @@ impl<'a> ModuleDeclaration<'a> {
| Self::TSNamespaceExportDeclaration(_) => None, | Self::TSNamespaceExportDeclaration(_) => None,
} }
} }
pub fn with_clause(&self) -> Option<&WithClause<'a>> {
match self {
Self::ImportDeclaration(decl) => decl.with_clause.as_ref(),
Self::ExportAllDeclaration(decl) => decl.with_clause.as_ref(),
Self::ExportNamedDeclaration(decl) => decl.with_clause.as_ref(),
Self::ExportDefaultDeclaration(_)
| Self::TSExportAssignment(_)
| Self::TSNamespaceExportDeclaration(_) => None,
}
}
} }
#[derive(Debug, Hash)] #[derive(Debug, Hash)]

View file

@ -35,6 +35,11 @@ pub(super) fn print_export_declaration<'a>(
parts.push(source.format(p)); parts.push(source.format(p));
} }
if let Some(with_clause) = decl.with_clause() {
parts.push(space!());
parts.push(with_clause.format(p));
}
if let Some(doc) = print_semicolon_after_export_declaration(p, decl) { if let Some(doc) = print_semicolon_after_export_declaration(p, decl) {
parts.push(doc); parts.push(doc);
} }

View file

@ -1,4 +1,4 @@
js compatibility: 258/586 (44.03%) js compatibility: 264/586 (45.05%)
# Failed # Failed
@ -261,20 +261,10 @@ js compatibility: 258/586 (44.03%)
### import-assertions ### import-assertions
* import-assertions/empty.js * import-assertions/empty.js
* import-assertions/re-export.js
### import-assertions/bracket-spacing
* import-assertions/bracket-spacing/empty.js
* import-assertions/bracket-spacing/re-export.js
### import-attributes ### import-attributes
* import-attributes/empty.js * import-attributes/empty.js
* import-attributes/keyword-detect.js * import-attributes/keyword-detect.js
* import-attributes/re-export.js
### import-attributes/bracket-spacing
* import-attributes/bracket-spacing/empty.js
* import-attributes/bracket-spacing/re-export.js
### label ### label
* label/comment.js * label/comment.js