fix(es/typescript): Strip declaration of exported function overloads (#9397)

- Closes https://github.com/swc-project/swc/issues/9396
This commit is contained in:
magic-akari 2024-08-08 14:25:06 +08:00 committed by GitHub
parent d479cc2914
commit 5c8aa522da
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 12 additions and 8 deletions

View File

@ -0,0 +1,6 @@
---
swc_fast_ts_strip: patch
swc_core: patch
---
fix(es/typescript): Strip declaration of exported function overloads

View File

@ -655,14 +655,6 @@ impl Visit for TsStrip {
n.visit_children_with(self);
}
fn visit_fn_decl(&mut self, n: &FnDecl) {
if n.function.body.is_none() {
self.add_replacement(n.function.span);
return;
}
n.visit_children_with(self);
}
fn visit_import_decl(&mut self, n: &ImportDecl) {
if n.type_only {
self.add_replacement(n.span);
@ -955,6 +947,9 @@ impl IsTsDecl for Decl {
Self::Var(ref var) => var.declare,
Self::Fn(FnDecl { declare: true, .. })
| Self::Class(ClassDecl { declare: true, .. }) => true,
Self::Fn(FnDecl { function, .. }) => function.body.is_none(),
_ => false,
}
}

View File

@ -0,0 +1 @@

View File

@ -0,0 +1 @@
export { };

View File

@ -0,0 +1 @@
export function f();