Skip to content

Commit

Permalink
Handle class method overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Apr 7, 2023
1 parent e8b2e1e commit 8f6a528
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crates/swc_ecma_transforms_typescript/src/strip_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,35 @@ impl VisitMut for StripType {

n.visit_mut_children_with(self);
}

fn visit_mut_class_members(&mut self, n: &mut Vec<ClassMember>) {
n.retain(|member| match member {
ClassMember::TsIndexSignature(..) => false,
ClassMember::Constructor(Constructor { body: None, .. }) => false,

ClassMember::Method(ClassMethod {
is_abstract,
function,
..
})
| ClassMember::PrivateMethod(PrivateMethod {
is_abstract,
function,
..
}) => !is_abstract && function.body.is_some(),

ClassMember::ClassProp(
ClassProp { declare: true, .. }
| ClassProp {
is_abstract: true, ..
},
) => false,

_ => true,
});

n.visit_mut_children_with(self);
}
}

impl StripType {
Expand Down

0 comments on commit 8f6a528

Please sign in to comment.