mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 04:08:41 +00:00
refactor(rust): backport v1.82.0 changes to main branch first (#6690)
This commit is contained in:
parent
ce25c450fc
commit
1a90ec4b85
2 changed files with 35 additions and 38 deletions
|
|
@ -846,46 +846,43 @@ impl<'a> Gen for ExportNamedDeclaration<'a> {
|
|||
if self.export_kind.is_type() {
|
||||
p.print_str("type ");
|
||||
}
|
||||
match &self.declaration {
|
||||
Some(decl) => {
|
||||
match decl {
|
||||
Declaration::VariableDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::FunctionDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::ClassDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSModuleDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSTypeAliasDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSInterfaceDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSEnumDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSImportEqualsDeclaration(decl) => decl.print(p, ctx),
|
||||
}
|
||||
if matches!(
|
||||
decl,
|
||||
Declaration::VariableDeclaration(_)
|
||||
| Declaration::TSTypeAliasDeclaration(_)
|
||||
| Declaration::TSImportEqualsDeclaration(_)
|
||||
) {
|
||||
p.print_semicolon_after_statement();
|
||||
} else {
|
||||
p.print_soft_newline();
|
||||
p.needs_semicolon = false;
|
||||
}
|
||||
if let Some(decl) = &self.declaration {
|
||||
match decl {
|
||||
Declaration::VariableDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::FunctionDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::ClassDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSModuleDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSTypeAliasDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSInterfaceDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSEnumDeclaration(decl) => decl.print(p, ctx),
|
||||
Declaration::TSImportEqualsDeclaration(decl) => decl.print(p, ctx),
|
||||
}
|
||||
None => {
|
||||
p.print_ascii_byte(b'{');
|
||||
if !self.specifiers.is_empty() {
|
||||
p.print_soft_space();
|
||||
p.print_list(&self.specifiers, ctx);
|
||||
p.print_soft_space();
|
||||
}
|
||||
p.print_ascii_byte(b'}');
|
||||
if let Some(source) = &self.source {
|
||||
p.print_soft_space();
|
||||
p.print_str("from");
|
||||
p.print_soft_space();
|
||||
source.print(p, ctx);
|
||||
}
|
||||
if matches!(
|
||||
decl,
|
||||
Declaration::VariableDeclaration(_)
|
||||
| Declaration::TSTypeAliasDeclaration(_)
|
||||
| Declaration::TSImportEqualsDeclaration(_)
|
||||
) {
|
||||
p.print_semicolon_after_statement();
|
||||
} else {
|
||||
p.print_soft_newline();
|
||||
p.needs_semicolon = false;
|
||||
}
|
||||
} else {
|
||||
p.print_ascii_byte(b'{');
|
||||
if !self.specifiers.is_empty() {
|
||||
p.print_soft_space();
|
||||
p.print_list(&self.specifiers, ctx);
|
||||
p.print_soft_space();
|
||||
}
|
||||
p.print_ascii_byte(b'}');
|
||||
if let Some(source) = &self.source {
|
||||
p.print_soft_space();
|
||||
p.print_str("from");
|
||||
p.print_soft_space();
|
||||
source.print(p, ctx);
|
||||
}
|
||||
p.print_semicolon_after_statement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ impl<'a, 'b> PeepholeFoldConstants {
|
|||
| (ValueType::Boolean, ValueType::Boolean) => {
|
||||
let left_number = ctx.get_number_value(left)?;
|
||||
let right_number = ctx.get_number_value(right)?;
|
||||
let Ok(value) = TryInto::<f64>::try_into(left_number + right_number) else { return None };
|
||||
let value = left_number + right_number;
|
||||
// Float if value has a fractional part, otherwise Decimal
|
||||
let number_base = if is_exact_int64(value) { NumberBase::Decimal } else { NumberBase::Float };
|
||||
// todo: add raw &str
|
||||
|
|
|
|||
Loading…
Reference in a new issue