diff --git a/.changeset/fair-maps-move.md b/.changeset/fair-maps-move.md new file mode 100644 index 00000000000..317919d90c7 --- /dev/null +++ b/.changeset/fair-maps-move.md @@ -0,0 +1,6 @@ +--- +swc_core: patch +swc_typescript: patch +--- + +fix(typescript): Check whether the method is abstract when checking `is_overload` diff --git a/crates/swc_typescript/src/fast_dts/mod.rs b/crates/swc_typescript/src/fast_dts/mod.rs index 3403619bd3d..3e61548518f 100644 --- a/crates/swc_typescript/src/fast_dts/mod.rs +++ b/crates/swc_typescript/src/fast_dts/mod.rs @@ -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 diff --git a/crates/swc_typescript/tests/fast_dts_deno.rs b/crates/swc_typescript/tests/fast_dts_deno.rs index a35dfd279eb..76eb1ca4009 100644 --- a/crates/swc_typescript/tests/fast_dts_deno.rs +++ b/crates/swc_typescript/tests/fast_dts_deno.rs @@ -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(