Skip to content

Commit

Permalink
fix(typescript): Check whether the method is abstract when checking `…
Browse files Browse the repository at this point in the history
…is_overload` (#9678)

**Related issue:**

 - Closes #9656
  • Loading branch information
CPunisher authored Oct 25, 2024
1 parent b8d255b commit 78500af
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/fair-maps-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
swc_core: patch
swc_typescript: patch
---

fix(typescript): Check whether the method is abstract when checking `is_overload`
2 changes: 1 addition & 1 deletion crates/swc_typescript/src/fast_dts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ impl FastDts {
}
}
ClassMember::Method(method) => {
let is_overload = method.function.body.is_none();
let is_overload = method.function.body.is_none() && !method.is_abstract;
if !prev_is_overload || is_overload {
prev_is_overload = is_overload;
true
Expand Down
20 changes: 20 additions & 0 deletions crates/swc_typescript/tests/fast_dts_deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,26 @@ fn dts_class_decl_prop_infer_test() {
);
}

#[test]
fn dts_class_abstract_method_test() {
transform_dts_test(
r#"export abstract class Manager {
protected abstract A(): void;
protected B(): void {
console.log("B");
}
protected C(): void {
console.log("B");
}
}"#,
r#"export declare abstract class Manager {
protected abstract A(): void;
protected B(): void;
protected C(): void;
}"#,
);
}

#[test]
fn dts_var_decl_test() {
transform_dts_test(
Expand Down

0 comments on commit 78500af

Please sign in to comment.