mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
refactor(ast)!: remove ExportDefaultDeclarationKind::TSEnumDeclaration (#3666)
TypeScript doesn't support `export default enum id {}`
https://www.typescriptlang.org/play/?target=2&isolatedDeclarations=true&emitDeclarationOnly=true&isolatedModules=false&ts=5.5.1-rc#code/KYDwDg9gTgLgBAE2AMwIYFcA29gDt0C2cAlgnAN4C+QA
https://github.com/microsoft/TypeScript/issues/3320
This commit is contained in:
parent
e148a32ce3
commit
0578ece6a4
7 changed files with 3 additions and 12 deletions
|
|
@ -3315,7 +3315,6 @@ pub enum ExportDefaultDeclarationKind<'a> {
|
||||||
ClassDeclaration(Box<'a, Class<'a>>) = 65,
|
ClassDeclaration(Box<'a, Class<'a>>) = 65,
|
||||||
|
|
||||||
TSInterfaceDeclaration(Box<'a, TSInterfaceDeclaration<'a>>) = 66,
|
TSInterfaceDeclaration(Box<'a, TSInterfaceDeclaration<'a>>) = 66,
|
||||||
TSEnumDeclaration(Box<'a, TSEnumDeclaration<'a>>) = 67,
|
|
||||||
|
|
||||||
// `Expression` variants added here by `inherit_variants!` macro
|
// `Expression` variants added here by `inherit_variants!` macro
|
||||||
@inherit Expression
|
@inherit Expression
|
||||||
|
|
@ -3328,7 +3327,7 @@ impl<'a> ExportDefaultDeclarationKind<'a> {
|
||||||
match self {
|
match self {
|
||||||
Self::FunctionDeclaration(func) => func.is_typescript_syntax(),
|
Self::FunctionDeclaration(func) => func.is_typescript_syntax(),
|
||||||
Self::ClassDeclaration(class) => class.is_typescript_syntax(),
|
Self::ClassDeclaration(class) => class.is_typescript_syntax(),
|
||||||
Self::TSInterfaceDeclaration(_) | Self::TSEnumDeclaration(_) => true,
|
Self::TSInterfaceDeclaration(_) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -565,7 +565,6 @@ impl<'a> GetSpan for ExportDefaultDeclarationKind<'a> {
|
||||||
match self {
|
match self {
|
||||||
Self::ClassDeclaration(x) => x.span,
|
Self::ClassDeclaration(x) => x.span,
|
||||||
Self::FunctionDeclaration(x) => x.span,
|
Self::FunctionDeclaration(x) => x.span,
|
||||||
Self::TSEnumDeclaration(x) => x.span,
|
|
||||||
Self::TSInterfaceDeclaration(x) => x.span,
|
Self::TSInterfaceDeclaration(x) => x.span,
|
||||||
// `Expression`
|
// `Expression`
|
||||||
Self::BooleanLiteral(e) => e.span,
|
Self::BooleanLiteral(e) => e.span,
|
||||||
|
|
|
||||||
|
|
@ -991,7 +991,6 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for ExportDefaultDeclarationKind<'a> {
|
||||||
p.print_soft_newline();
|
p.print_soft_newline();
|
||||||
}
|
}
|
||||||
Self::TSInterfaceDeclaration(interface) => interface.gen(p, ctx),
|
Self::TSInterfaceDeclaration(interface) => interface.gen(p, ctx),
|
||||||
Self::TSEnumDeclaration(enum_decl) => enum_decl.gen(p, ctx),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1233,7 +1233,6 @@ impl<'a> Format<'a> for ExportDefaultDeclarationKind<'a> {
|
||||||
Self::FunctionDeclaration(decl) => decl.format(p),
|
Self::FunctionDeclaration(decl) => decl.format(p),
|
||||||
Self::ClassDeclaration(decl) => decl.format(p),
|
Self::ClassDeclaration(decl) => decl.format(p),
|
||||||
Self::TSInterfaceDeclaration(decl) => decl.format(p),
|
Self::TSInterfaceDeclaration(decl) => decl.format(p),
|
||||||
Self::TSEnumDeclaration(decl) => decl.format(p),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,7 @@ fn print_semicolon_after_export_declaration<'a>(
|
||||||
match_expression!(ExportDefaultDeclarationKind) => Some(ss!(";")),
|
match_expression!(ExportDefaultDeclarationKind) => Some(ss!(";")),
|
||||||
ExportDefaultDeclarationKind::FunctionDeclaration(_)
|
ExportDefaultDeclarationKind::FunctionDeclaration(_)
|
||||||
| ExportDefaultDeclarationKind::ClassDeclaration(_)
|
| ExportDefaultDeclarationKind::ClassDeclaration(_)
|
||||||
| ExportDefaultDeclarationKind::TSInterfaceDeclaration(_)
|
| ExportDefaultDeclarationKind::TSInterfaceDeclaration(_) => None,
|
||||||
| ExportDefaultDeclarationKind::TSEnumDeclaration(_) => None,
|
|
||||||
},
|
},
|
||||||
ModuleDeclaration::ExportAllDeclaration(_)
|
ModuleDeclaration::ExportAllDeclaration(_)
|
||||||
| ModuleDeclaration::ExportNamedDeclaration(_)
|
| ModuleDeclaration::ExportNamedDeclaration(_)
|
||||||
|
|
|
||||||
|
|
@ -249,8 +249,7 @@ impl ModuleRecordBuilder {
|
||||||
match_expression!(ExportDefaultDeclarationKind) => None,
|
match_expression!(ExportDefaultDeclarationKind) => None,
|
||||||
ExportDefaultDeclarationKind::FunctionDeclaration(func) => func.id.as_ref(),
|
ExportDefaultDeclarationKind::FunctionDeclaration(func) => func.id.as_ref(),
|
||||||
ExportDefaultDeclarationKind::ClassDeclaration(class) => class.id.as_ref(),
|
ExportDefaultDeclarationKind::ClassDeclaration(class) => class.id.as_ref(),
|
||||||
ExportDefaultDeclarationKind::TSInterfaceDeclaration(_)
|
ExportDefaultDeclarationKind::TSInterfaceDeclaration(_) => return,
|
||||||
| ExportDefaultDeclarationKind::TSEnumDeclaration(_) => return,
|
|
||||||
};
|
};
|
||||||
let export_entry = ExportEntry {
|
let export_entry = ExportEntry {
|
||||||
export_name: ExportExportName::Default(exported_name.span()),
|
export_name: ExportExportName::Default(exported_name.span()),
|
||||||
|
|
|
||||||
|
|
@ -3054,9 +3054,6 @@ pub(crate) unsafe fn walk_export_default_declaration_kind<'a, Tr: Traverse<'a>>(
|
||||||
ExportDefaultDeclarationKind::TSInterfaceDeclaration(node) => {
|
ExportDefaultDeclarationKind::TSInterfaceDeclaration(node) => {
|
||||||
walk_ts_interface_declaration(traverser, (&mut **node) as *mut _, ctx)
|
walk_ts_interface_declaration(traverser, (&mut **node) as *mut _, ctx)
|
||||||
}
|
}
|
||||||
ExportDefaultDeclarationKind::TSEnumDeclaration(node) => {
|
|
||||||
walk_ts_enum_declaration(traverser, (&mut **node) as *mut _, ctx)
|
|
||||||
}
|
|
||||||
ExportDefaultDeclarationKind::BooleanLiteral(_)
|
ExportDefaultDeclarationKind::BooleanLiteral(_)
|
||||||
| ExportDefaultDeclarationKind::NullLiteral(_)
|
| ExportDefaultDeclarationKind::NullLiteral(_)
|
||||||
| ExportDefaultDeclarationKind::NumericLiteral(_)
|
| ExportDefaultDeclarationKind::NumericLiteral(_)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue