mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
refactor(transformer): panic on illegal cases in TS namespace transform (#3477)
Panic on function or class declaration without `id`. This should be impossible.
This commit is contained in:
parent
8e089a9f2d
commit
7e7b4526ba
1 changed files with 4 additions and 12 deletions
|
|
@ -105,15 +105,11 @@ impl<'a> TypeScript<'a> {
|
||||||
}
|
}
|
||||||
// Collect bindings from class, function, variable and enum declarations
|
// Collect bindings from class, function, variable and enum declarations
|
||||||
Statement::FunctionDeclaration(ref decl) => {
|
Statement::FunctionDeclaration(ref decl) => {
|
||||||
if let Some(ident) = &decl.id {
|
names.insert(decl.id.as_ref().unwrap().name.clone());
|
||||||
names.insert(ident.name.clone());
|
|
||||||
}
|
|
||||||
new_stmts.push(stmt);
|
new_stmts.push(stmt);
|
||||||
}
|
}
|
||||||
Statement::ClassDeclaration(ref decl) => {
|
Statement::ClassDeclaration(ref decl) => {
|
||||||
if let Some(ident) = &decl.id {
|
names.insert(decl.id.as_ref().unwrap().name.clone());
|
||||||
names.insert(ident.name.clone());
|
|
||||||
}
|
|
||||||
new_stmts.push(stmt);
|
new_stmts.push(stmt);
|
||||||
}
|
}
|
||||||
Statement::TSEnumDeclaration(ref decl) => {
|
Statement::TSEnumDeclaration(ref decl) => {
|
||||||
|
|
@ -196,15 +192,11 @@ impl<'a> TypeScript<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Statement::ClassDeclaration(ref decl) => {
|
Statement::ClassDeclaration(ref decl) => {
|
||||||
decl.bound_names(&mut |id| {
|
names.insert(decl.id.as_ref().unwrap().name.clone());
|
||||||
names.insert(id.name.clone());
|
|
||||||
});
|
|
||||||
new_stmts.push(stmt);
|
new_stmts.push(stmt);
|
||||||
}
|
}
|
||||||
Statement::FunctionDeclaration(ref decl) => {
|
Statement::FunctionDeclaration(ref decl) => {
|
||||||
decl.bound_names(&mut |id| {
|
names.insert(decl.id.as_ref().unwrap().name.clone());
|
||||||
names.insert(id.name.clone());
|
|
||||||
});
|
|
||||||
new_stmts.push(stmt);
|
new_stmts.push(stmt);
|
||||||
}
|
}
|
||||||
Statement::TSEnumDeclaration(ref enum_decl) => {
|
Statement::TSEnumDeclaration(ref enum_decl) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue