Skip to content

Commit

Permalink
fix(es/typescript): Strip declaration of exported function overloads (#…
Browse files Browse the repository at this point in the history
…9397)

- Closes #9396
  • Loading branch information
magic-akari authored Aug 8, 2024
1 parent d479cc2 commit 5c8aa52
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/eleven-dryers-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_fast_ts_strip: patch
swc_core: patch
---

fix(es/typescript): Strip declaration of exported function overloads
11 changes: 3 additions & 8 deletions crates/swc_fast_ts_strip/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/swc_fast_ts_strip/tests/fixture/issue-9396.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { };
1 change: 1 addition & 0 deletions crates/swc_fast_ts_strip/tests/fixture/issue-9396.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export function f();

0 comments on commit 5c8aa52

Please sign in to comment.